Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
I need to add and show tab on permission

I am using the material UI tab what my task is I need to show the tab only when it permission is true I am done that part but what if permission come false it will not work it throw an error because of this I am not able to hide tab...

const permission = {
  corp_permission: false,
  user_permission: true
};
export default function LabTabs() {
  const classes = useStyles();
  const [value, setValue] = React.useState("1");

  const handleChange = (event, newValue) => {
    setValue(newValue);
  };

  return (
    <div className={classes.root}>
      <TabContext value={value}>
          <TabList onChange={handleChange} aria-label="simple tabs example">
            <Tab label="Item One" value="1" />
            {permission.corp_permission == true && (
              <Tab label="Item Two" value="2" />
            )}
            <Tab label="Item Three" value="3" />
            {permission.user_permission == true && (
              <Tab label="Item Four" value="4" />
            )}
          </TabList>
        <TabPanel value="1">Item One</TabPanel>
        <TabPanel value="2">Item Two</TabPanel>
        <TabPanel value="3">Item Three</TabPanel>
        <TabPanel value="4">Item four</TabPanel>
      </TabContext>
    </div>
  );
}

CodeSandBox Link

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In case you haven't figured it out already, here:

https://codesandbox.io/s/material-demo-forked-cubew?file=/demo.js

Note: MUI v4 code is a mess at places, so I definitely recommend upping to v5.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda