Failed to execute 'replaceChild' on 'Node': The node to be replaced is not a child of this node.
I have a store:
of this type:
I'm trying to render only part of these countries, or rather their sprites. I filter them out and render them like this:
In short you can toggle between different
mapSkin()
and different characters()
, both of which currently have two settings.
It works OK when you go from no characters selected to a few selected, or when you seemingly replace all the sprites, but as soon as the resulting list expands or contracts I get the omnious error:
I have had this error for a few weeks now. Am I using stores incorrectly?6 Replies
@ryansolid I came across your reply here:
https://github.com/solidjs/solid/discussions/366#discussioncomment-459799
It might be able to help me. I am trying out your <Key> implementation but do you think reconcile and createState are better? I have never used them before and I would guess they require a lot more set up?
Key only works one level deep basically. Where the reconcile and store can diff down to a greater level of detail. I usually go for stores.
Thanks for the answer! Sadly I am already using a store and I still have problems (OP). I'm going through the tutorial again for now.
I have a store to hold all the local data fetched so far from the back-end, but maybe I need another store that more closely resembles my web GUI?
I.e. a list of Countries that should be rendered as elements instead of trying to conditionally extract a subset from my main store?
Hmm.. that's an odd error, it suggests that DOM nodes are getting moved in an unexpected way. That's a rendering error. The store is probably related, but this error happens when there are references to DOM nodes.. things getting inserted outside of the framework usually..
You were right. I am passing the elements to mapbox-gl which is a bit unpredictable when it creates/removes markers using these provided components. It changed the DOM in in a way Solid seemingly can't predict, which is also inefficient.
Instead I opted to load all possible countries (which could be 1000s) and try to hide their main content with a <Show>.
Hopefully this is how it should be done, because I don't fully knows how Solid works under the hood, but I guess it gets messed up when its own proxy doesn't conform to the DOM.
Yeah Solid doesn't observe the DOM and just keeps references. It assumes it is in the state it is left in from a declarative standpoint. There is some flexibility in terms of being able to augment on top of that but if it falls back to Solid doing updates from declarative templates it won't have known if things have moved when it expects them to be there.