redux-form : How to display form values on another component

前端 未结 4 1053
小蘑菇
小蘑菇 2021-01-13 00:34

I am using redux-form 6.0.0-rc.5 and I am trying to display the form values as they are entered by the user.

However, I want these values to be displayed from anothe

4条回答
  •  无人共我
    2021-01-13 01:10

    Starting from redux-form 6.0.0 (and still the same in 7.0.0), you can use the function formValueSelector() to select values from any redux form you have in your application: http://redux-form.com/7.0.0/docs/api/FormValueSelector.md/

    import { connect } from 'react-redux';
    import { formValueSelector } from 'redux-form';
    
    const selector = formValueSelector('formName');
    
    List = connect(
      state => ({
        name: selector(state, 'name')
      })
    )(List)
    

提交回复
热议问题