我想知道如何在 FieldArray 内的 Field 组件上触发异步验证。我有类似的东西:
class MyForm extends Component {
constructor(props) {
super(props)
}
render() {
const { handleSubmit } = this.props
return (
<form onSubmit={handleSubmit}>
<Field
name="name"
type="text"
component={RenderInputField}
/>
<FieldArray
name="hobbies"
component={RenderHobbies}
/>
</form>
)
}
}
MyFormBase = reduxForm ({
form: 'MyForm',
validate,
asyncValidate,
asyncBlurFields: ['name', 'hobbies.hobby']
})(MyFormBase)
渲染爱好为:
const RenderHobbies = ({fields}) => (
<div>
{fields.map((hobby, index) => ({
<Field
name={`${hobby}.hobby`}
component={RenderInputField}
/>
}))}
</div>
)
export default RenderHobbies
这是行不通的。异步验证将在模糊时触发“name”,但不会触发“hobbies.hobby”。正确的语法是什么?
我正在寻找的语法是:
asyncBlurFields: ['hobbies[].hobby']
很简单,我只是在文档中找不到它。我通过经历找到了它this https://github.com/erikras/redux-form/issues/869 thread
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)