2 ms·
Yeah, I was keeping the explanation shorter. The React docs generally advise that apps try not to use context directly, as the API has limitations, and _will_
by acemarke 9y ago
Yeah, I was keeping the explanation shorter.
The React docs generally advise that apps try not to use context directly, as the API has limitations, and _will_ change in some future React release once they figure out a better approach. The main issue is that context updates are blocked if a component returns `false` from `shouldComponentUpdate` (and the same for a PureComponent). As a result, context is best suited for references that won't change, such as pubsub event emitters.
Michel Weststrate's post "How to safely use React context" [0] is excellent, and Ken Wheeler just gave a good talk about context at React Boston [1].
[0] https://medium.com/@mweststrate/how-to-safely-use-react-context-b7e343eff076 https://medium.com/@mweststrate/how-to-safely-use-react-cont...
[1] http://reactboston.surge.sh/#/ http://reactboston.surge.sh/#/