Value isn't updating
I'm working on a browser game with Excalibur.js and Solid, and most of it is working as expected. But this one nested value, while definitely changing, isn't updating in my <For> component. I've tried using an <Index> as well, but the value doesn't update either way.
The currentHP outside of the For loop does update, but the values in the For do not. Can someone help me figure out what I may be doing wrong?
5 Replies
any way that you could make a minimal reproduction of it in the solid playground?
I forgot to link to the repo: https://github.com/Totality-Games/base-tower-tactics
The snippet in the post comes from
/src/components/menus/combat/CombatMenu.tsx
.
Running pnpm dev:setup
will have the project at localhost:9999
.
The snippets that change the currentHP
value are in /src/actors//combatUtils/EnemyUnit.ts
:
GitHub
GitHub - Totality-Games/base-tower-tactics
Contribute to Totality-Games/base-tower-tactics development by creating an account on GitHub.
And in
/src/actors/combatUtils/GridAttackSquares.ts
:
You didn't update
currentHP
via setStore
so it won't work
Signal systems generally only support primitives and plain objects and arrays. Some libraries have tried to support class instances, but they're having issues with private fields
You can make the class field a signal so it's reactive, but i'm not sure whether you should do it
Thank you Simon. That is good info! I'm still pretty new to signals so I tried getting this to work for a week now with no luck. Making the field a signal does seem to work, so I'll do it like this for now unless it causes more issues down the line lol.
Gracias!