Reputation: 2471
I have redux-form
where I have input field when it is touched it shows error if there are any. Now I want reset the input fields touched property to false
when page is reloaded . how do I do it?
I am using redux-persist
to persist state so I have to explicitly do this so I need a way set touched property to false in componentDidMount
.
Upvotes: 1
Views: 1108
Reputation: 4068
Haven't touched redux-form
for a while, so please bear with any problem in my sample code.
Redux-form's action creators can be used normally as dispatcher. You just need to import the action and use it in mapDispatchToProps
:
import { untouch } from 'redux-form/actions'
...
componentDidMount() {
const fieldArray = getFields() // your own methods
this.props.untouch(fieldArray)
}
...
const mapStateToProps = (dispatch) => ({
untouch: (fieldArray) => dispatch(untouch("YOUR_FORM_NAME", fieldArray))
})
Upvotes: 2