I am not passing in any special config settings nor am I setting/or calling Destroy... but my state is being cleaned... anyway to prevent this? I need the state to stick around as I need that data thruout my application.
prev state: I see it in there... via redux-logger action: redux-form/Destroy next state: it's gone.
B) Simply unmount your form component For many use cases, you will want to either hide your form component after submission succeeds or navigate away to another page, which will cause redux-form 's default behavior of destroying the form data in the reducer in componentWillUnmount .
Redux Form is very easy to use and implement, we just have to wrap our form component with the HOC provided by Redux Form and we are good to go. Applying validation to the form is very easy in Redux Form, we can apply validation to all the fields as well as validations for individual fields.
There is no “right” answer for this. Some users prefer to keep every single piece of data in Redux, to maintain a fully serializable and controlled version of their application at all times.
The form's state subtree is destroyed when the form is unmounted, by design. This is the default and expected behaviour.
From v6.2.1 onwards there is a form config property destroyOnUnmount
, which explicitly enables/disables the state-clearing behaviour on a specific form (docs here)
import { reduxForm } from 'redux-form'; reduxForm({ form: 'example', destroyOnUnmount: false })(...)
This is useful when you have a form whose state you wish to preserve if the user abandons it halfway though, navigates away, and then returns later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With