Closed chinmaypant21 closed 9 months ago
There is no re-render trigger while updating an array stored in a signal using array splice. Here is an example of the issue:
const tasks = signal<any[]>(['Task1', 'Task2', 'Task3']); const Screen = () => { function handleRemoveTask(idx: number){ activeWindows.value.splice(idx,1) )) } return ( <>...</> ) }
Signals can only rerender if you assign new value with .value property. Splice is a mutating array in place. So you need to use: tasks.value = tasks.value.toSpliced(...)
.value
tasks.value = tasks.value.toSpliced(...)
Yup. working as intended.
There is no re-render trigger while updating an array stored in a signal using array splice. Here is an example of the issue: