What is React Context future?


(Volodymyr Parandii) #1

Hello React Community!

Recently, during exploring of a new React V16.0.0 documentation, I’ve found this mind-breaking statement:

If you want your application to be stable, don’t use context. It is an experimental API and it is likely to break in future releases of React.
(https://reactjs.org/docs/context.html#why-not-to-use-context)

Being used Context api previously in narrow cases, where it was REALY needed, I’ve found this information very challenging :slight_smile:

So what is the suggested future of React Context API? Would it be replaced with an external module, some new pattern or removed at all? Any thoughts?

Many thanks!


(Bogdan Savluk) #2

This warning is there for a quite long time… And indeed context api was changing, in react 0.14 there was breaking changes about how it functions internally.

At the moment, many projects are relying or context feature(react-router or react-redux for example), so it is not likely to be removed, but API might be subject of change. It is recommended to limit context usage to as small area as possible (to make it easier to upgrade if API is changed).

Also in general, in many cases there might be better options instead of using it - so think twice when considering to use it :wink: .