Using React Contexts for Nested Components

InstructorJoe Maddalone

Share this video with your friends

Send Tweet

Contexts are currently undocumented in React v0.12.2, so use at your own risk. However they provide a particularly nice solution to passing data down through nested components.

Marcus
~ 9 years ago

Coming from AngularJS, this looks like an inherited scope, whereas using props seems to be more as the isolated wcope. When working with larger projects, nesting will not scale well. If you have a structure App > Menu > Login and you have stuff in your App used by Login, that's just a bit confusing, but bad enough.

But then we add a component in another part of the structure App > ... > LockedArticle that depends on that same nested state. A programmer will have to trace down who does what and when. This is exactly what Flux was made to avoid according to their web page.