-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TabView/TabPanel: Can't have TabPanels in a JSX fragment #5900
Comments
Of course, a workaround is to do { myCondition && (<TabPanel header="Conditional panel 1" />)}
{ myCondition && (<TabPanel header="Conditional panel 2" />)}
{ myCondition && (<TabPanel header="Conditional panel 3" />)} but this is not good practice and can quickly become difficult to maintain. |
TabPanel should have a visible property so you can do this. <TabPanel header="Conditional panel 1" visible={myCondition} /> |
Thanks @melloware ! I suppose that's pretty much the same as the workaround as we'd have to copy-paste |
yeah it makes to me more readable code though and we have |
Describe the bug
Use case: want to conditionally render several TabPanels. To do this, the code would ideally look something like:
However in this case, the conditional panels don't show up, even when
myCondition
is true.Reproducer
https://stackblitz.com/edit/vitejs-vite-gyvk7d?file=src%2FApp.tsx
PrimeReact version
10.4.0
React version
18.x
Language
ALL
Build / Runtime
Next.js
Browser(s)
Chrome 121
Steps to reproduce the behavior
See reproducer (can reproduce in Vite but also other builds / runtimes)
Expected behavior
TabPanels should show
The text was updated successfully, but these errors were encountered: