React dynamically changes style

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.

Mar.03,2021

your style changes according to val.select. What is it about this.config.select?


your value has changed, but render Ken Ben didn't render it again. You just changed the value of this.config.select .
you add a

{val.select}

to see if there is any value.
must use setState to change state so that render can re-render DOM .


you output this config value in action has changed, but has your store value changed? You output config under render to see if your value has changed

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eaa5f0-1fd3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eaa5f0-1fd3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?