UNPKG

750 BJavaScriptView Raw
1'use strict';
2
3var bindAutoBindMethods = require('./bindAutoBindMethods');
4
5/**
6 * Updates a React component recursively, so even if children define funky
7 * `shouldComponentUpdate`, they are forced to re-render.
8 * Makes sure that any newly added methods are properly auto-bound.
9 */
10function deepForceUpdate(component) {
11 if (component._instance) {
12 // React 0.13
13 component = component._instance;
14 }
15
16 bindAutoBindMethods(component);
17
18 if (component.forceUpdate) {
19 component.forceUpdate();
20 }
21
22 if (component._renderedComponent) {
23 deepForceUpdate(component._renderedComponent);
24 }
25
26 for (var key in component._renderedChildren) {
27 deepForceUpdate(component._renderedChildren[key]);
28 }
29}
30
31module.exports = deepForceUpdate;
\No newline at end of file