3 ms·
It looks like this could make use of React's context feature once #2112 [1] lands. I have similarish form components [2] which need to do this the hacky way in
by insin 12y ago
It looks like this could make use of React's context feature once #2112 [1] lands.
I have similarish form components [2] which need to do this the hacky way in the meantime (cloning [3] their children in order to pass the form prop they need all the way down):
<forms.RenderForm form={ProductForm} initial={this.props.product} ref="productForm">
<Container>
<Row>
<Field name="productName" md="8"/>
<Field name="tags" md="4"/>
</Row>
...
[1] https://github.com/facebook/react/issues/2112 https://github.com/facebook/react/issues/2112
[2] https://github.com/insin/newforms-bootstrap https://github.com/insin/newforms-bootstrap
[3] http://facebook.github.io/react/docs/clone-with-props.html http://facebook.github.io/react/docs/clone-with-props.html
- feedjoelpie 12y agoSo are you traversing the entire tree of children here? I'm familiar with cloneWithProps, but I've been wary about this technique because of how deep the components I actually want to bind could be and how much traversal it could take to find them.