Skip to content

React: Disabling Tabs conditionally #2510

Answered by gloriliale
pgarciamunoz asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @pgarciamunoz!
The easiest way to do this is to add a state to your application. This way, you can check that state and set the disabled prop to be true if the role is apprentice, and false if it is not (or use more complex logic that makes most sense for your app). Here's a codesanbox that shows this in action in the simplest way. I also included a button that changes the state of the app so you can see that the tab becomes disabled/not disabled when the state changes.

Let me know if that helps and if you have any other questions!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gloriliale
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants