Is it possible to use For inside Switch to create multiple Match from array?
Not as things are. Switch expects Match children and For creates dynamic children that are different. Switch is the only example of doing this sort of compound component that has specific expectations of its children. It is possible to create a component with this behavior I imagine. We might even be able to have For work here. But we need to change how Switch works to detect when it is getting passed a function instead of an array.
Thanks.
I'm just trying to determine how complicated it is. Given one layer is simple enough but N level of nested dynamic tags need to be resolved before reading any conditions. Like what if the the For has Shows or Switches in it. The final match might be inside another Match.
Is the use case trying to codify the switch as data and then have it render from that data? And I'm gathering the matches can change dynamically after initial render? Otherwise using a simple Array.prototype.map would be sufficient. Understanding this helps me prioritize work. This is completely doable in userland so my gut is to just consider the question answered and move on but I'm always interested in understanding better.
Is the use case trying to codify the switch as data and then have it render from that data?
I am writing an app and there is routing section. I wanted to use For inside Switch to create Matches from routes array instead of hardcoding every Match myself. Exactly like simple-routing exmaple from github page, except using For.
I wanted to be as simple as possible like simple routing example from github page. I did not want to make a Router component. I wanted to use solid builtin features wherever possible. I am trying to understand the solid better by doing this app.
For sure. Something that might be worth looking at is the Dynamic component. https://github.com/ryansolid/solid/blob/master/documentation/rendering.md#dynamic
If the code is possible to be iterated with a For maybe it's possible to just be a single component that takes the data as props. Let me know if that makes sense. You basically pass in the routed component to the Component prop, all other props pass through to it.
EDIT:
And like said before it sounds like you are working a fairly simple case so maybe just using array.map inside switch is sufficient and that should work. Just not For. It won't add new routes dynamically but usually these things are a fairly fixed structure.
Going to leave as is for now. Closing due to lack of activity.