Redux表单中的字段组件从何处获取输入道具?
从中了解redux表单,但不了解如何将输入道具提供给字段组件,如下所示:Redux表单中的字段组件从何处获取输入道具?,redux,react-redux,redux-form,Redux,React Redux,Redux Form,从中了解redux表单,但不了解如何将输入道具提供给字段组件,如下所示: class MyCustomInput extends Component { render() { const { input: { value, onChange } } = this.props return ( <div> <span>The current value is {value}.</span> <
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>
)
}
}
字段是一个高阶组件,它将这些属性应用于传递给
组件的任何内容。它可以有效地确定字段需要什么值以及如何连接到redux存储,具体取决于您传入的组件以及字段的其他属性
源代码可能是这方面最好的真相来源。您可以在createFieldProps函数中看到此处定义输入的位置:
字段是一个高阶组件,它将这些属性应用于传递给组件的任何内容。它可以有效地确定字段需要什么值以及如何连接到redux存储,具体取决于您传入的组件以及字段的其他属性
源代码可能是这方面最好的真相来源。您可以在createFieldProps函数中看到此处定义输入的位置:
import MyCustomInput from './MyCustomInput'
...
<Field name="myField" component={MyCustomInput}/>