如何让自定义的 redux-form 组件控制多个字段?
How to make a custom redux-form component control multiple fields?
我想要一个 Map
,带有可确定 x
和 y
字段的可拖动标记。
<Fields names={['x', 'y']} component={Map} />
当标记被放置到地图上的新位置时,我如何告诉 redux-form 新的 x
和 y
值是什么?
const renderMap = props => (
<DragDrop
image={props.image}
currentValue={{
x: props.x.input.value,
y: props.y.input.value,
}}
thingsChanged={coords => {
props.x.input.onChange(coords.x);
props.y.input.onChange(coords.y);
}} />
)
<Fields
names={['x', 'y']}
component={renderMap}
image={this.state.image} />
我想要一个 Map
,带有可确定 x
和 y
字段的可拖动标记。
<Fields names={['x', 'y']} component={Map} />
当标记被放置到地图上的新位置时,我如何告诉 redux-form 新的 x
和 y
值是什么?
const renderMap = props => (
<DragDrop
image={props.image}
currentValue={{
x: props.x.input.value,
y: props.y.input.value,
}}
thingsChanged={coords => {
props.x.input.onChange(coords.x);
props.y.input.onChange(coords.y);
}} />
)
<Fields
names={['x', 'y']}
component={renderMap}
image={this.state.image} />