Conversation
| > Context is an advanced and experimental feature. The API is likely to change in future releases. | ||
| > | ||
| > Most applications will never need to use context. Especially if you are just getting started with React, you likely do not want to use context. Using context will make your code harder to understand because it makes the data flow less clear. It is similar to using global variables to pass state through your application. | ||
| > Context is an advanced and experimental feature. If you are not an experienced React developer, you do not want to use context. If you are getting annoyed by passing props down manually through many levels of a tree, first try using [Redux](https://github.com/reactjs/redux) or [MobX](https://github.com/mobxjs/mobx). |
There was a problem hiding this comment.
This makes it seem like these libraries offer an abstraction on top of context. However they don't: libraries you link to are independent of React.
There are React bindings for these libraries which happen to use context, but they are called differently (React Redux, mobx-react) and are in separate repos.
This paragraph also makes it seem like passing data down is the primary responsibility of these libraries. But both Redux and MobX are much more opinionated about state handling in general.
There was a problem hiding this comment.
OK - i basically redid this part
| ## Known limitations | ||
| ## Known Limitations | ||
|
|
||
| If a context value provided by a component changes, descendants that use that value won't update if an intermediate parent returns `false` from `shouldComponentUpdate`. See issue [#2517](https://github.com/facebook/react/issues/2517) for more details. |
There was a problem hiding this comment.
In general I feel like not enough time is spent explaining that this is an experimental API and it is likely to break in the future. Unlike props it is likely you'll have to change every single component that he uses context when we change its API.
Also even though you describe how updates work they are just broken. The limitation in the last sentence is very severe because it is completely out of control of the components using context. So essentially you can consider updates to context broken, abd we should recommend treating it as unchanging because it's the only way to use it safely. You can still pass your own subscription system through it.
This is a really good article about it. I'm not sold on its conclusion ("wrap everything with MobX") because MobX wraps all native data structures into its own, and has its share of issues related to that, but the rest of the article highlights pitfalls of context very well:
https://medium.com/@mweststrate/how-to-safely-use-react-context-b7e343eff076
There was a problem hiding this comment.
OK, I added a bunch more about "why not to use context". I also just added a link to that article.
|
How's this? |
|
LGTM |

The content is mostly similar to how it was before. I added a mention of Redux and MobX, because in several of the situations described by this document, people should really consider using one of those libraries before they start messing with context themselves.