Conditionally Show/Hide Routes in expo-router + BottomTabNavigator (withLayoutContext) #28878
-
I'm using I use Using file-based routing, with a structure like:
...everything seems to work fine. I get a bottom tab navigator, with 3 tabs. Switching between them updates the URL, etc. However, I want to be able to conditionally show/hide the "admin" tab depending on state, as shown below in the code:
Instead of the desired behaviour (2 tabs) the tab is still rendered. In fact, even if I remove this from the code:
...the tab is still rendered which, I suppose, is because the file-based routing finds it. Is there a way for me to achieve what I want and only show the tab, in the bottom navigator, if the isAdmin state is true? Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I eventually figured it out... For my admin Tab screen I can add a
Epiphany moment from this video. |
Beta Was this translation helpful? Give feedback.
I eventually figured it out...
For my admin Tab screen I can add a
redirect
prop as such:Epiphany moment from this video.