Closed isolin closed 1 year ago
Arrays aren't internally reactive, so you would need to create a new array with the contents of the old array, along with a new element.
state.arr.value = [...state.arr.value, "123"]
Thank you very much for the explanation. I didn't notice the todos.value = [...todos.value, { text: text.value }];
in the example in the official docs.
Now it works fine for me!
Hi! I started using preact and signals just recently. Maybe I am doing something wrong, but I thing I just followed the TODO List example in the docs. Please let me know if this is a bug or just my mistake. Note that I am using typescript.
This is my global state exported and shared all over the app.
Then I have the control elements like
The
Arr
component initially displays Length: 1 but when I push a new value to the array the length does not get updated. The console output called inonClick
correctly shows the increasing number of items as I keep pressing the button.I work with Firefox, the preact packages are: