私はonClickeイベントを持つ反応コードを持っています。私は関数(someFunction)の実装を取得すると仮定します。このコードを実行してもエラーは発生しませんでした。私は問題が機能していると思う。リアクトコードあなたは交換する必要がありますonClickイベントはReactJSで動作しません
class Hello extends Component {
constructor() {
super();
this.num = { number: 4 };
this.someFunction = this.someFunction.bind(this);
}
someFunction() { this.setState({ number: this.num.number + 3 }); }
render() {
const coco = {
color: 'blue',
background: 'yellow',
width: '200px',
height: '200px',
padding: 'lem'
};
return (<div style={coco} onClick={this.someFunction}>
<p style={coco} onClick={this.someFunction}> bly blya
Hello {this.props.name} </p>
<p style={coco} onClick={this.someFunction} >
Current count: {this.num.number + 3}
</p>
</div>)
}
}
render(<Hello/>, document.getElementById('container'));