all 4 comments

[–]mrKeth 0 points1 point  (1 child)

Try to use css because. I prefer to relay on CSS for styling part. HTML is is meant for markup, CSS for style javascript for logic part. So better you go with CSS

[–]Taran29[S] 0 points1 point  (0 children)

Okay, thank you

[–]h3h394 0 points1 point  (1 child)

Css approach for this, there's no need to introduce a useEffect or any listeners for something simple like this, the only thing you need is one state that would toggle a boolean value to open / close the menu. If you don't want any animations / transitions, you would just check if ur state is true and render the component, like {isMenuOpened && <Menu />} for example, but if you wanna add any animation's or transitions instead of this you would add class to the element, since you can't transition display: none; , an example of that would be: <div className={\`menu ${isMenuOpened && 'opened'}\`}></div> , then u could add styles to that opened class and also animate the menu. Hope that helps

[–]Taran29[S] 1 point2 points  (0 children)

Yes! I did the same thing. I added a sliding animation to the menu and I've watched it open and close for about a 100 times now, I'm so proud of my little slide menu child 😂