this is my code i'm trying to add a class on click to a clicked div but i have more than 1 div have the same classname so when i click to any div the toggle class added to all divs not the one which i clicked what i want to know how can i specify the div which i want to add toggle class to it
Code:
const [isActive, setActive] = useState(false); const toggleClass = () => { setActive(!isActive) console.log('sad') } return ( <div className="command_wrapper"> <div className="command_list"> { Commands.map((item, index) => { return ( <div className="command" > <div className="command_face" onClick={toggleClass}> <h1>{item.Command}</h1> <p>{item.Description}</p> </div> <div className={isActive ? "command_body" : "disapper"}> <div className="command_usage"> <h1>Usage</h1> <p>{item.Usage}</p> </div> <div className="command_required"> <h1>Required Permissions</h1> <p>{item.premissions}</p> </div> </div> </div> ) }) } </div> </div> ```