Redux-form: how to mount the redux-form reducer at the child node of the state tree?

Created on 6 Jul 2016  路  3Comments  路  Source: redux-form/redux-form

redux-form version: 5.3.1

redux version: 3.2.1

I mount the redux-form reducer at the child node and it take a error:

 Uncaught Error: You need to mount the redux-form reducer at "form"

form

So can I mount the redux-form reducer not at the top-level of the state tree?

Regards.

Most helpful comment

You've closed this, so perhaps you have the answer, but the answer, for future visitors is:

You can specify a getFormState(state) => redux-form slice config parameter to accomplish this. So, if you really wanted to (there is rarely a good reason) do what you're doing, you could do:

OperatorManagementForm = reduxForm({
  form: 'operatorManagementForm',
  getFormState => state => state.operatorManagementReducer.form
})(OperatorManagementForm)

All 3 comments

You've closed this, so perhaps you have the answer, but the answer, for future visitors is:

You can specify a getFormState(state) => redux-form slice config parameter to accomplish this. So, if you really wanted to (there is rarely a good reason) do what you're doing, you could do:

OperatorManagementForm = reduxForm({
  form: 'operatorManagementForm',
  getFormState => state => state.operatorManagementReducer.form
})(OperatorManagementForm)

Thank you @erikras for the answer! The docs don't show a sample how to use this. I have many modules in my app which has a huge state. I want to separate forms per module at least. having all forms in one top level branch of the store is going to get nasty fast. So using getFormState in multiple branches spares me from big trouble later on when the store grows.

BTW, minor typo: getFormState : state => state.operatorManagementReducer.form (fat arrow instead colon)

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Aaronius picture Aaronius  路  3Comments

captainkovalsky picture captainkovalsky  路  3Comments

2easy picture 2easy  路  3Comments

rob-mcgrail picture rob-mcgrail  路  3Comments

shanewho picture shanewho  路  3Comments