react-redux-form
react-redux-form copied to clipboard
<Field /> component suggestions:
- Currently
<Field />allows a consumer to provide a function atprops.children, and in this case, passes the relevantfieldValueto that function.
- I'm curious whether we should also pass
modelValue? I don't understand internals of rrf well enough to know whether this is ever not fully redundant withfieldValue.value. - I wonder if we should support passing
props.renderto do exactly whatprops.childrendoes (when props.children is a function). We could easily supportrenderandchildrenboth to avoid breaking changes, and this would have a consistent API with<Control />.
- Currently
<Field />does not augment the context with itsresolvedModel. Instead, the context remains unchanged under a field component. This gives me unexpected results when doing:
<Fieldset model='.one'>
<Field model='.two'>
{(fieldValue) => (
// in here fieldValue is the fieldValue for '...one.two'
<Fieldset model='.three'>
{
// in here context.model is '...one.three' instead of '...one.two.three'
}
</Fieldset>
)}
</Field>
</Fieldset>
My suggestion is that we have Field augment context.model in the same way that <Fieldset /> does.
The reason I'm using <Field/> in this way is specifically because I want to read fieldValue at this point in the tree. Perhaps the better way to handle my suggestion is to, well, add a render prop to <Fieldset /> which passes the relevant fieldValue.
Worth mentioning, I guess, that I'm very happy to do all the work for whatever's decided here. Just interested in feedback on the ideas.
@joshacheson These seem like good ideas, and I'd be happy to review a PR swiftly if you decide to implement them.