import React from 'react';
class App extends React.Component {
constructor() {
super();
this.state = {
data: 'First Comes First Serves'
}
this.updateState = this.updateState.bind(this);
};
updateState(e) {
console.log(e);
// console.log(e.target);
this.setState({data: e});
}
render() {
return (
<div>
<Content myDataProp = { this.state.data } updateStateProp = { this.updateState }></Content>
</div>
);
}
}
class Content extends React.Component {
render() {
return (
<div>
<input type="text" value={ this.props.myDataProp } id="id" />
<div>
<button onClick={ this.props.updateStateProp(document.getElementById('id').value )}>Click</button>
</div>
<h3>{ this.props.myDataProp }</h3>
</div>
);
}
}
export default App;
エラー; 未知の型エラー:nullのプロパティ '値'を読み取れません実数値null DOM操作
私はReactで非常に新しいです。ここで
は、入力値は「最初に来..」(私は仮定)として割り当てられていますが、エラーは、事前に感謝を表示されます。
ありがとうございます。それは問題を解決した – NewPHPer