Closed athanclark closed 5 years ago
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!
From what I understand, React 16.x supports this whole "context" paradigm, where a value can be propagated from a
Provider
down to childConsumers
, however the component that is wrapped by aConsumer
should be accepted via an explicitcontextType
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 additionalcase
statement in the top levelswitch
in the src/React.js file would probably do the trick, but I wanted to start the discussion here before amending it.