Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!