jschr / form-provider

React components for building forms and managing state.
1 stars 2 forks source link

set form state from on props update #9

Open jschr opened 7 years ago

jschr commented 7 years ago

Currently createForm is only called on componentWillMount. If props change and the form's initial state depends on props it won't be updated.

Add a value prop to <FormProvider> to allow for updating the form state if props have changed. Also paves the way for improved composability.

<FormProvider form={form} value={props.user} onSubmit={saveUser}>
...
</FormProvider>
jschr commented 7 years ago

This may make withForm accepting a function of props redundant.