私は反応が新しくなりました。コンストラクタの状態をレンダリングメソッドに渡そうとしましたが、私のh1は表示されません。反応コンストラクタで変数を定義できませんでした
class Mod extends React.Component {
constructor(props) {
super();
this.state = {
title : 'Hello world'
};
//this worked!
document.title = this.state.title;
}
render() {
return(
<div>
<h1>{this.title}</h1>
</div>
)
}
}
これは、スポットの違いのゲームです。 *あなたが何を変えたのか、*なぜ*を言ってください。 –