Skip to content

Commit c3803b9

Browse files
author
menelike
committed
replace Math.random() when enforcing an update
1 parent 365584f commit c3803b9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/react-meteor-data/useTracker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function areHookInputsEqual(nextDeps, prevDeps) {
6262
return true;
6363
}
6464

65+
let uniqueCounter = 0;
6566
function useTracker(reactiveFn, deps) {
6667
const previousDeps = useRef();
6768
const computation = useRef();
@@ -113,7 +114,7 @@ function useTracker(reactiveFn, deps) {
113114
// use Math.random() to trigger a state change to enforce a re-render
114115
// Calling forceUpdate() triggers componentWillUpdate which
115116
// calls the reactive function and re-renders the component.
116-
forceUpdate(Math.random());
117+
forceUpdate(++uniqueCounter);
117118
}
118119
})
119120
));

0 commit comments

Comments
 (0)