Child Component not Re-rendering
So I have this code
When player inventory is set via the interval (note that it's state does change) the weapon component doesn't re-render. I've tried a lot of things and can't get it to.
6 Replies
1. Why is the
setInterval
in a createEffect
?
See https://www.solidjs.com/tutorial/introduction_signals?solved
2. Weapon
doesn't "re-render" as such anyway. The change would propagate via the reactive props
. So what might be happening is that reactivity is broken inside of the nested component (perhaps due to props
destructuring) so that it would only show the initial prop value but not the updates.SolidJS
Solid is a purely reactive library. It was designed from the ground up with a reactive core. It's influenced by reactive principles developed by previous libraries.
1. to create the interval as soon as the page is loaded
also i think you're right regarding the 2nd point
This isn't React
does it not need to be inside the createeffect?
No.
createEffect
exist so that changes in the reactive values can manipulate the outside world.
So you would use createEffect
to observe the change in a reactive value with console.log()
.i see
fixing the inner component to not use prop destructing fixed the issue