私はリアクションを使用して入力フォームを作成しています。 すべての子供の入力があり、値を保存するための独自の状態がありますが、どのように親を処理するかわかりません。私が反応にあまり入力でCOMPEXフォームの使用方法のいくつかの例を見つけることができますリアクト・ハンドル状態の更新
class FormComponent extends Component {
constructor(props) {
super(props);
this.state = {
title: null,
someAmount: null
}
}
render() {
let me = this;
return (
<div>
<TextField
value={me.state.title}
onChange={(proxy, value) => {
me.setState({title: value})
me.hanleChnage();
}
}
/>
<TextField
value={Number.parseFloat(me.state.someAmount)}
onChange={(proxy, value) => {
if (!isNaN(Number.parseFloat(value))) {
me.setState({someAmount: value})
me.hanleChnage();
}
}
}
/>
</div>
)
}
handleChange() {
//Calling the parent
//State here is outdated
this.props.onUpdate && this.props.onUpdate(this.state);
}
}
export default FormComponent;
または:ここ は一例です。 ありがとう!
ScoobyDrew18は正解ですが、このテクニックを習得したときに還元式を調べます – artSir