contextType constructor property
athanclark opened this issue · 3 comments
From what I understand, React 16.x supports this whole "context" paradigm, where a value can be propagated from a Provider down to child Consumers, however the component that is wrapped by a Consumer should be accepted via an explicit contextType property - here's the React docs that detail it.
Should we make this an additional field in the ReactSpecOptional row? I think it's a pretty simple non-breaking change, and an additional case statement in the top level switch in the src/React.js file would probably do the trick, but I wanted to start the discussion here before amending it.
contextType is a static property, while the ReactSpec fields are bound at instance construction. This field would need to be configured at class construction like componentWithDerivedState does.
Note, that you don't need the static property to use context. You can use createLeafElement myContext.consumer { children: \value -> ... }
Oh, well shoot haha. So the contextType is something like propTypes or whatever? Yeah, I think it's a good idea to just leave it to the typechecker. Thank you!