I have a Collection component and when I click on a div in this component, I want to change both the className of the Collection component and the className of the first sibling component after the Collection component.
With UseState, I could only change the className of the component I was in.
My Collection.js looks like this:
const Collection = () => {
const [toggleClass, setToggleClass] = useState(false);
function handleClick() {
setToggleClass((toggleClass) => !toggleClass);
}
let toggleClassCheck = toggleClass ? "passive" : "active";
return (
<React.Fragment>
<div className={`step ${toggleClassCheck}`}>
<div className="atrium">
<span>Collection</span>
</div>
<div className="content">
<div
className="moreThenOne"
area="collectionTitle"
onClick={handleClick}
>
Can anyone help me on how to do the process I mentioned above?