Component with only <For /> in it removes all HTML children
I have this set up:
Where the outer div is used as a reference to attach a Mapbox-gl canvas element, along with some more HTML elements. But I also fill it with some components of my own "MapCountry".
My problem is that when mainStore.countries is an empty list, Solid removes all children of my outer div, including the elements created by Mapbox-gl.
My current work-around is to add a dummy element to the outer div:
Is this the best solution? Could I prevent solid from removing all items?
3 Replies
Why not put the ref on the dummy div so that your component and the canvas are siblings?
Just wrap the For loop in <Portal>
Goated solution! Thank you for introducing me to Portals :)
That was a good idea, but I realized I needed my <MapCountry> components in a specific element in Mapbox-gl for the paning and zooming to work correctly.