-
-
Notifications
You must be signed in to change notification settings - Fork 119
Open
Description
- Check if updating to the latest version resolves the issue
Environment
- I am using
@preact/signals-core - I am using
@preact/signals - I am using
@preact/signals-react- I understand usage changed in v2, and I've followed the React Integration instructions
Describe the bug
In JavaScript, NaN === NaN evaluates to false. A consequence of this is that a signal with the value NaN will trigger an update if the value is again assigned as NaN. In the worst case, this might lead to an infinite loop with a two-way UI binding if the receiving end is also treating NaN in the same way.
To Reproduce
const x = signal(0);
effect(() => console.log(x.value));
x.value = NaN;
x.value = x.value;This logs NaN twice even though it's expected that the last row shouldn't lead to running the effect again.
Expected behavior
Expected that the dirty checking logic has a special case for re-assigning NaN
Metadata
Metadata
Assignees
Labels
No labels