在 redux-form 中设置输入字段 touched equal false
Setting input fields touched equal false in redux-form
我有 redux-form
我有输入字段,当它被触摸时它会显示错误(如果有的话)。现在我想在重新加载页面时将触摸的输入字段 属性 重置为 false
。我该怎么做?
我正在使用 redux-persist
来保持状态,所以我必须明确地这样做,所以我需要一种在 componentDidMount
.
中将 touched 属性 设置为 false 的方法
好久没接触redux-form
,请多多包涵我的示例代码中的问题。
Redux-form 的 action creators 可以正常用作 dispatcher。您只需要导入操作并在 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))
})
我有 redux-form
我有输入字段,当它被触摸时它会显示错误(如果有的话)。现在我想在重新加载页面时将触摸的输入字段 属性 重置为 false
。我该怎么做?
我正在使用 redux-persist
来保持状态,所以我必须明确地这样做,所以我需要一种在 componentDidMount
.
好久没接触redux-form
,请多多包涵我的示例代码中的问题。
Redux-form 的 action creators 可以正常用作 dispatcher。您只需要导入操作并在 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))
})