implement a simple requirement to change color with the click of a button (react + mobx)
render() {
return (
<div className="begin">
<h3></h3>
<div className="options-box">
{
this.store.config.map((val, index) => {
return (
<span onClick={this.select.bind(this, index)} key={index}>
<i style={{backgroundColor: val.select ? "-sharp365dea" : "-sharpFFF"}}></i>
{val.title}</span>
)
})
}
</div>
</div>
);
}
select
is an action
@action select = (index) => {
this.config[index].select = !this.config[index].select
console.log(this.config[index].select);
}
Click the button to find that this.config.select
is changed, but the color of the button has not changed. Ask God to tell me how to solve it.