redux-form is Destroying my state once the component is unmounted, what gives?

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)