onChange属性を使用してprops
経由で子コンポーネントに渡す関数を介して状態を更新したいとします。この一方で関数を経由して関数を渡して更新する
<input className="minutes" type="number" defaultValue={ this.props.minutes } onChange={ this.props.updatePreferences("minutes", this.value) }/> minutes.
は、親コンポーネント内の関数である:これは、子コンポーネントである
<Route exact path="/" render={props => <Welcome minutes = {this.state.minutes}
interests = {this.state.interests}
sayHello = {this.sayHello}
updatePreferences = {this.updatePreferences} />} />
'onChange = {this.props.updatePreferences(" minutes "、this.value)}'を 'onChange = {()=> this.props.updatePrに変更してみてくださいeferences( "分"、this.value)} '。 – adrice727
ありがとうございますが、動作していません。入力するとコンソールに何も表示されません。 – ocram