Next.js Discord

Discord Forum

Only showing the component in a list that is equal to the state

Bendire's Thrasher posted this in #help-forum
Open in Discord
Bendire's ThrasherOP
On my app I have several table components I would like to display, but only when they have been selected. I am looking for a way to achieve this via useState and somehow only show the component that is equal to the state. I've been unable to do this so far, any suggestions would be greatly appreciated!

2 Replies

Bendire's ThrasherOP
I found a way and have done it implementing this code:
{table === 'reportOverview' && <ReportOverviewTable reportOverview={reportOverview} table={table} />}
I have read it is bad to use && for conditional rendering, is this true?