Beginner React developer here.
here is my state and function that toggles a ul from display:none to display:block
const [dropDown, setDropdown] = useState('hidden')
const [icon, setIcon] = useState('\u2795')
const handleHidden = () => {
if (dropDown === 'hidden') setDropdown('active')
if (dropDown === 'active') setDropdown('hidden')
if (icon === '\u2795') setIcon('\u2796')
if (icon === '\u2796') setIcon('\u2795')
}
the icons just toggle between a unicode "+" and "-"
and a corresponding onClick function to toggle between the two classes:
<span onClick={() => handleHidden()} className='plus-minus'>{icon}</span></h3>
in addition to this code I map through an array of students and diplay all their values in a div.
The problem is when I click the span all the items open and close (expectedly). what would be the next steps to having only the item that I click open and close while the rest stay hidden?