reactjstypescriptnext.jsmaterial-uiclassname

Why can't I enter the code? mui tag conditional


Why can't I use boolean?

I want to check whether I am an admin or not. and hide the button or disable the button

 const Authenticate = useSelector(userSelector)
  let check :boolean = true;

<Link href="/stock" passHref className={Authenticate.level != 'admin' ? check=false:check=true}> // className redline
          <ListItem
            button
            className={router.pathname === "/stock" ? "Mui-selected" : ""}
            disabled={check}
          >
            <ListItemIcon>
              <Layers />
            </ListItemIcon>
            <ListItemText primary="Stock" />
          </ListItem>
        </Link>

enter image description here


Solution

  • I can do it after I put

    disabled={Authenticate.level == 'admin' ? false:true} 
    

    in <ListItem>

    thank everyone