To render conditionally or not to render conditionally?
Unanswered
SteveGremory posted this in #help-forum
G'morning!
So basically I have to render 4 different tables based on application state and I could just make 4 components and conditionally render them, but my OCD isn't allowing me to do this as it sounds like the worst possible way to do it. I looked into conditional routing but nah too complex for this. Should I just go with the 4 components thing?
So basically I have to render 4 different tables based on application state and I could just make 4 components and conditionally render them, but my OCD isn't allowing me to do this as it sounds like the worst possible way to do it. I looked into conditional routing but nah too complex for this. Should I just go with the 4 components thing?
4 Replies
The thing is that I wanna do this in the most ideal way possible and don't wanna have issues in the future when I add more types of tables to be rendered. Sounds kinda messed up but I don't think i'm doing the best job at explaining it.
To start from the beginning:
- I have a table with 5 rows, cool
- Now, if a user wants to group by a row, I wanna remove 3 extra rows and only show 2 rows.
- I also don't want the user to switch pages every now and then so the way I designed it is that you can toggle a switch and the table should swap out for another one on the same page, no page re-loading.
- To do this, I think I'll need to go like:
- I have a table with 5 rows, cool
- Now, if a user wants to group by a row, I wanna remove 3 extra rows and only show 2 rows.
- I also don't want the user to switch pages every now and then so the way I designed it is that you can toggle a switch and the table should swap out for another one on the same page, no page re-loading.
- To do this, I think I'll need to go like:
currentState == "StateOne" ? <ComponentOne props... /> : currentState == "StateTwo" ? ... : ...or make it a little more humane and use a function to do that
the thing is, I don't really wanna do that, it's clumsy and I'm sure there's a better way