0
初めて反応してみたが、固まってしまった。状態が定義されていないsetStateの使用時にエラーが発生する
class HelloWorldComponent extends React.Component {
constructor(props){
super(props);
this.state = {
price
}
}
render() {
return (
<div>
<input type="text" onChange={e => this.setState({price: e.target.value})} placeholder="main price"/>
<input type="text" placeholder="custom price"/>
</div>
);
}
}
上記のコードに問題がありますか?価格は定義されていませんか?私はすでに
this.state = {
price
}
正しい:
はこのスニペットをチェックしてください。私も同じようにチェックしていました。私の答えは間違っています。 – Ved