【发布时间】:2016-10-17 23:03:28
【问题描述】:
从page 了解 redux-forms,但不明白如何将 input props 提供给 Field 组件,如下所示:
class MyCustomInput extends Component {
render() {
const { input: { value, onChange } } = this.props
return (
<div>
<span>The current value is {value}.</span>
<button type="button" onClick={() => onChange(value + 1)}>Inc</button>
<button type="button" onClick={() => onChange(value - 1)}>Dec</button>
</div>
)
}
}
MyCustonInput 从哪里获得input 属性?该示例仅在下面显示:
import MyCustomInput from './MyCustomInput'
...
<Field name="myField" component={MyCustomInput}/>
【问题讨论】:
标签: redux react-redux redux-form