Reputation: 43
I make a button to control the menu but I click the button and then nothing happen.There aren't run out any error msg.
const [display, changeDisplay] = useState('none')
const [Icon, setIcon] = useState(<HamburgerIcon />)
function Close() {
return (
<Box as='button' onClick={() => changeDisplay('none')}><CloseIcon /></Box>
)
}
<Box
as="button"
aria-label="Open Menu"
position="relative"
onClick={() => { changeDisplay('flex'); setIcon(<Close />) }}
display={{ base: 'inline-block', md: 'none' }}
margin={2}
>
{Icon}
</Box>
Upvotes: 0
Views: 66
Reputation: 226
replace the following code:
onClick={() => { changeDisplay('flex'); setIcon(<Close />) }}
with:
onClick={() => {changeDisplay('flex'); setIcon(Close())}}
Upvotes: 1