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?