0
ボタングループに単語の配列をマップしました。インデックスと色値を持っている状態でReactjs、状態データ付きインラインスタイル
this.state = {
selectedWordIndex:'', //e.g. 3
selectedWordColor:'' //e.g. rgb(137,197,8)
}
インデックスと色は別の機能に設定されています。
var counter = -1;
return this.state.sentenceArray.map((word) => {
counter += 1
return (
<button
key={counter}
type="button"
className="btn btn-default"
style={{}}>{word}</button>);});
インデックスボタンの色を変更するにはどうすればよいですか?
完璧、それは動作します:) –