Skip to content

JSXElement in createSignal or createMemo, when the page changes, it disappears on the page. #1981

Answered by danieltroger
wizardAEI asked this question in Q&A
Discussion options

You must be logged in to vote

So what happens when you do <b>test</b> is that it will actually evaluate to a HTMLElement (the same as calling document.createElement("b")).

That means that every time that value is used it's the same element. Some constrains apply to elements regarding to the DOM, like this one that I think is what you're running into:

  1. One element can only be in the DOM once, if you try to insert it again it will automatically get removed from the old place

What solid usually does to work around this, is not evaluating <b />at the time of creation of the object that should contain it, but first when it's needed, using a getter. That way you insert the value on your object multiple times into the DOM b…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wizardAEI
Comment options

Answer selected by ryansolid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1979 on December 08, 2023 17:25.