The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Using React Contexts for Nested Components

Using React Contexts for Nested Components

2:02
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.
Watch this lesson now
Avatar
egghead.io

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.

Avatar
Jim

I've been loving Cortex lately for this issue and passing event changes back up. https://github.com/mquan/cortex

In reply to egghead.io
Avatar
Marcus

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.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?