react-menu
react-menu copied to clipboard
When using library inside of a component the CSS is bugging after page is reloaded.
I am trying to use the library to generate a drop down menu from a button within a component.
Like so:
![Screenshot 2022-08-03 at 16 18 41](https://user-images.githubusercontent.com/46694996/182617930-03db0ff0-1e45-47a8-ac11-57c751e7a2ba.png)
The library is working on most cases, however if I reload the page and try to use the drop down again this happens:
![Screenshot 2022-08-03 at 16 18 51](https://user-images.githubusercontent.com/46694996/182618051-0fd0b707-15c6-47cd-8a4f-8fd65cbf939e.png)
The functionality is still there (e.g. if I click on the text fields that popped up they still redirect where they are supposed to, however the css is bugged).
Anyone experienced this too or knows where the problem might be?
Here the snippet of my code where I use the Menu
![Screenshot 2022-08-03 at 16 25 39](https://user-images.githubusercontent.com/46694996/182619180-088432d7-b57c-41d1-bbbd-0adac3175934.png)
Thanks
Hi @paoloviselli , your code looks good to me. The only issue is MenuButton
wraps a Button
which is not necessary. You might use Button
for the menuButton
prop directly. But I think this is not related to the styling bug in your code.
Are you using the default index.css
that comes with the npm package? If so, is the css still applied after page is reloaded?
Hi @szhsin I am using the default index.css
however the CSS kept disappearing each time I reloaded the page.
I had to install Material UI for other components and I ended up using also their Menu
and the MUI Menu, used in the same exact code does not present that issue.
However the weird thing was that I was using your Menu library on another page of my project and it was not presenting this issue at all. The only difference in this use was the fact that is was not nested into any components. Might be that the problem?
Hope this helps.
Nesting the menu into components is totally fine. You could use browser dev tools to inspect what css has been applied to menu before and after the page is reloaded.
Also, you don't have to use the index.css
. The css rules in the file can be copied into your project stylesheets or CSS-in-JS solution.