My redux-form is reinitialized when switching language by changing react-intl wrapper props

后端 未结 2 507
名媛妹妹
名媛妹妹 2021-01-14 11:37

I\'m wrapping my app inside an IntlProvider from react-intl v2, like this:



        
2条回答
  •  孤城傲影
    2021-01-14 12:06

    We encountered the same issue when combining react-relay with redux-form. The solution was simple: we initialize the form when the form is mounted.

    compose(
      createContainer({
        fragments: {
          viewer: () => Relay.QL`
            fragment on User {
              nickname
              email
            }
          `
        }
      }),
      reduxForm({
        form: "user",
        fields: ["nickname", "email"],
      })
    )(
      class UserForm extends Component {
        componentWillMount() {
          this.props.initializeForm(this.props.viewer)
        }
    
        render() {
          // Same as before
        }
      }
    )
    

提交回复
热议问题