How to get Redux Form data in another Component

后端 未结 2 1319
滥情空心
滥情空心 2020-12-06 18:58

How can i pass the data from redux form, So that i can access that data in App.js? here is the code i have written using redux-form.after i click on submit the data should b

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 19:52

    The above mentioned answer is absolutely correct however, when your form component gets unmounted the state may get destroyed and then it will not be available in any other component.To fix this you can add destroyOnUnmount: false to your reduxForm wrapper like this

    export default reduxForm({
      form: 'form',
      destroyOnUnmount: false, 
    })(Form)

    Now you can get the form data in any component by following the above answer. Hope this helps

提交回复
热议问题