Get the content dynamically and push it to the array



export default class App extends React.Component{
  
  state = {
expand: flase,
renList: []
  }    
 handleCheck = value => {
const { expand, renList} = this.state;
this.setState({ expand: !expand });
renList.push(value)
  }
 
render() {
  return(
    <div>
    {list.map(subItem => (
       <div>
        <div className={`${css.sunKind} ${(this.state.expand === true ? 
          css.active : null)}`} onClick={() => 
            this.handleCheck(subItem)}>
          {subItem.name}
       </div>
    </div>
))}
   </div>
  )
}
  }

after rendering the content, if you want to click on one of them, it will be selected, and then add the class name active to the setting you click on, and add it to the renList. If you don"t select it, you won"t add it. When you click on it, you will add active to all the div. How do you modify it now?

Feb.22,2022

when handleCheck, you can operate on list instead of renList push data, pass the current index, find the current subitem content in list, and then add a field. This field can be used to add active

.
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-1b3a422-2ba47.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-1b3a422-2ba47.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?