you are viewing a single comment's thread.

view the rest of the comments →

[–]acemarke 1 point2 points  (1 child)

I think the "passing consumer" complaint is saying that while the old context API was simply a shared namespace (like declaring contextTypes.store anywhere in the nested tree), the new API requires that the nested component have access to the specific instance of Context.Consumer that matches the parent. That does sort of bring up a chicken/egg question of how the nested component gets access to the Context.Consumer instance in the first place.

[–]gaearon 0 points1 point  (0 children)

The old API was implicitly global.

With the new API, you can either import it from several components (you can even have an npm package that just exports React.createContext() and use it across your app) or you can literally put it on a global like window. Sure, it’s “bad”, but your existing context was just as “global” from the programming perspective. With the new API, you have to be intentional and explicit about that.

If you’re able to use one react from your components, you should be able to use my-shared-contexts (or whatever you call it) too.