【发布时间】:2018-08-02 13:34:59
【问题描述】:
我在我的表单中使用了多个 redux-form 的 Field 实例,并将 redux-form-material-ui 的 TextField 作为可渲染组件:
<Field
component={TextField}
floatingLabelText='Title:'
name='title'
/>
当表单所在的组件被 reduxForm() 包裹时,我们会在该组件中得到props.pristine、props.dirty 等。
但是,我想根据pristine 的值,在另一个非reduxForm 组件或Redux 状态下执行一些操作,但我无法这样做。
我尝试将它作为道具传递给 Field:
<Field
component={TextField}
floatingLabelText='Title:'
name='title'
pristine={props.pristine}
/>
但是pristine 属性仍然既不是作为state.form.formName 内部的道具出现,也不是作为道具出现
里面state.form.formName.registeredFields.title:
问题:
有没有办法在另一个组件或 redux 状态中获取我的表单的 pristine 属性?
【问题讨论】:
标签: reactjs redux material-ui redux-form