Currently I am using redux-form
, and now I have to connect my reduxForm
component to my redux
storage. So, looking at the docs I have to do something like:
// Decorate with reduxForm(). It will read the initialValues prop provided by connect()
InitializeFromStateForm = reduxForm({
form: 'initializeFromState' // a unique identifier for this form
})(InitializeFromStateForm)
// You have to connect() to any reducers that you wish to connect to yourself
InitializeFromStateForm = connect(
state => ({
initialValues: state.account.data // pull initial values from account reducer
}),
{ load: loadAccount } // bind account loading action creator
)(InitializeFromStateForm)
export default InitializeFromStateForm
I did something like that in my component but, eslint
is giving me an error:
no-class-asign
Should I disable this rule for using it with redux-form
or does exist a way to manage this kind of things?
You don't really need to reassign the class. Why not do something like
// Decorate with reduxForm(). It will read the initialValues prop provided by connect()
const reduxFormDecorator = reduxForm({
form: 'initializeFromState' // a unique identifier for this form
});
const reduxConnector = connect(
state => ({
initialValues: state.account.data // pull initial values from account reducer
}),
{ load: loadAccount } // bind account loading action creator
);
export default reduxConnector(reduxFormDecorator(InitializeFromStateForm));