我正在尝试使用semantic-ui-redux-form-fields
创建一个编辑表单。表单工作正常,空白起点,但对于我有初始值的编辑表单,我无法使其工作。
如果我使用直接redux-form
,只要我有prop
传递到我的表单组件中,initialValues
的Field#component
就可以正常初始化表单。
使用该逻辑,我认为我需要做的就是将"input"
属性从{Input}
更改为currentValue
(/ w相应的导入)。请注意,我从未看到props
通过{initialValues: {"first_name": "Bob"}}
传入。目前尚不清楚这个道具将如何填充。
道具:
import { Form, Button } from 'semantic-ui-react'
import { reduxForm, Field} from 'redux-form'
...
return <Field component="input" type="text" name='first_name'/>
工作部分:
import { Form, Button } from 'semantic-ui-react'
import { reduxForm, Field} from 'redux-form'
import { Input } from 'semantic-ui-redux-form-fields'
...
return <Field component={Input} type="text" name='first_name'
currentValue={this.props.currentValue}/>
不工作组件:
Input
semantic-ui-react
中的defaultValue
组件有一个Field
道具,我相信你应该能够使用数据初始化Input
,因为你传递component
在它的<Field
component={Input}
defaultValue={this.props.currentValue}
name='first_name'
type='text'
/>
道具。
qazxswpoi