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

.
Menu