react-component / form

React High Order Form Component(web & react-native)
http://react-component.github.io/form/
MIT License
1.81k stars 296 forks source link

How to only call mapPropsToFields once? #203

Open vovanmix opened 6 years ago

vovanmix commented 6 years ago

Hi! I've got a feature request. I'm using this component with Apollo graphql. I pass down through the props both initial values for the form (when I need to edit an item) and the loading state of the Apollo mutation. When I submit the form and trigger the mutation, it causes mapPropsToFields to be called again and it results in all field values to be reset. The ideal solution for me will be the way to only allow mapPropsToFields to be called once, when the component is mounted. It can be a new property that may be false by default, but when true it won't call this method on any props change. I used https://github.com/jaredpalmer/formik before and it uses a similar approach.