React navigation goBack() issue

651 views Asked by At

Basically, i'm doing navigate using this.props.navigation.navigate('screenname') and for back functionality, I'm doing this.props.navigate.goBack(). Everything is working fine as per needed except one thing that is redux state value is not fetched from state when I'm doing goBack() from my active screen.

Example:

In screenA : (I did this)

this.props.navigation.navigate('screenB');

Now in screenB :

this.props.navigation.navigate('screenC')
//...few lines as per need on my project

const mapStateToProps = (state) => {
    return {
        formData: state.form.ReduxFormData.values
    }
};

and last one screenC :

this.props.navigation.goBack()

SO, my problem is now when i'm redirect to screenB from screenA on that time i'm able to get that state value into my formData props but when i'm goBack from screenC to screenB on that time state data is got undefined!!

Note:: I'm fetching reduxForm data into mapStateToProps

1

There are 1 answers

0
Nikhil Agarwal On BEST ANSWER

As mentioned by @gustavohenke on https://github.com/erikras/redux-form/issues/3372#issuecomment-326749903, please set the following property in reduxForm():-

destroyOnUnmount: false

I verified that it works.