UNPKG

704 BJavaScriptView Raw
1var deepForceUpdate = require('./deepForceUpdate');
2
3var isRequestPending = false;
4
5module.exports = function requestForceUpdateAll(getRootInstances) {
6 if (isRequestPending) {
7 return;
8 }
9
10 /**
11 * Forces deep re-render of all mounted React components.
12 * Hat's off to Omar Skalli (@Chetane) for suggesting this approach:
13 * https://gist.github.com/Chetane/9a230a9fdcdca21a4e29
14 */
15 function forceUpdateAll() {
16 isRequestPending = false;
17
18 var rootInstances = getRootInstances(),
19 rootInstance;
20
21 for (var key in rootInstances) {
22 if (rootInstances.hasOwnProperty(key)) {
23 deepForceUpdate(rootInstances[key]);
24 }
25 }
26 }
27
28 setTimeout(forceUpdateAll);
29};
\No newline at end of file