2 ms·
Note that context updates do require that React walk over the component tree to find the appropriate consumers, and that itself has a cost. In fact, at the mom
by acemarke 8y ago
Note that context updates do require that React walk over the component tree to find the appropriate consumers, and that itself has a cost. In fact, at the moment, it seems to be _relatively_ expensive, per the discussion in this issue : https://github.com/facebook/react/issues/13739 https://github.com/facebook/react/issues/13739 .
We're actually working on converting React-Redux to use `createContext` in version 6. I had hoped that it would be a big performance improvement, but unfortunately our (admittedly limited) perf benchmarks indicate that the experimental v6 branches are slower than our current v5 release build. In v5, the individual connected components subscribe to the Redux store, and can bail out of calling `setState()` if no update is necessary. In v6, we've only got one subscription (in `<Provider>`), but any Redux store update requires that React walk the tree and update the context consumers so they can run `mapState`. So, React _always_ gets involved, whereas before we might skip React if nothing had changed.
Per that issue, I'm hopeful that the React team can optimize deep context updates in the near future.