0
子のプロパティを変更しようとしましたが失敗しました。私は反応のライフサイクルの方法のほとんどを試しましたが、それらのどれも働かないようでした(didMount propsUpdateなど)。親のコンポーネントのプロパティを更新します。
すべてのヘルプは、私はあなたの質問から理解するものから
http://codepen.io/yogainalift/pen/KMPvNz
var Field = React.createClass({
getInitialState: function() {
return {
message: this.props.setMessage || 'should change this one'
}
},
render() {
return (
<div>
{this.state.message}
</div>
)
}
});
var App = React.createClass({
getInitialState: function() {
return {
inputField: ''
}
},
handle(event) {
console.log(event.target.value);
this.setState({
inputField: event.target.value
})
},
render() {
return (
<div>
<input type='text' placeholder='changing this text' onChange={this.handle}/>
<Field setMessage={this.state.inputField} />
</div>
)
}
});
ReactDOM.render(<App />, document.getElementById('app'));
は長らく頑張ってくれてありがとうございました! –