Home > Software engineering >  React button not applying css until refresh Material UI
React button not applying css until refresh Material UI

Time:01-22

I have used the following syntax for adding the buttons in the side menu. All works well, but the button attribute does not show up until a refresh is done.

                <ListItem
                  button={true}
                  key="Home"
                  onClick={() => {
                    toggleSidebar();
                    navigate("/home", { replace: false });
                  }}
                >
                  <ListItemIcon>
                    <HomeIcon />
                  </ListItemIcon>
                  <ListItemText primary="Home" />
                </ListItem>


This is how it looks like on first load:-

On first load

After I refresh the page:-

Upon refresh

CodePudding user response:

<ListItem button={bool} is deprecated use ListItemButton instead.

enter image description here

  •  Tags:  
  • Related