One of the components in my project is a Material-UI AppBar, which consists of various elements such as icons and buttons. Here is the code snippet for this component:
import React from 'react'
import AppBar from 'material-ui/AppBar'
import AccountCircle from 'material-ui-icons/AccountCircle'
import Toolbar from 'material-ui/Toolbar'
import IconButton from 'material-ui/IconButton'
import HomeIcon from 'material-ui-icons/Home'
import Button from 'material-ui/Button'
import auth from './../auth/auth-helper'
import {Link, withRouter} from 'react-router-dom'
// Code for isActive function...
const Menu = withRouter(({history}) => (
<AppBar position="static">
// Code for rendering various buttons based on user authentication status...
</AppBar>
))
export default Menu
The AppBar appears correctly when not logged in, with the Home
icon on the left and SIGNIN
button on the right.
https://i.sstatic.net/AnYuY.png
After logging in, all elements are positioned as expected, but upon page refresh, some buttons move to the center:
https://i.sstatic.net/5QQEL.png
To prevent this displacement issue, I am considering adding a condition to the isActive function or passing parameters like left
or right
to dynamically set the style of each button. Any suggestions or thoughts on resolving this?