Skip to content

Setting $state with NaN causes updates #14545

@trueadm

Description

@trueadm

Describe the problem

When setting state with NaN it causes an update even though NaN is the same value as before.

<script>
	let x = $state(NaN);
</script>

<button onclick={() => {
	x = NaN
}}>Set NaN</button>

{#key x}
	<iframe title="Svelte" src="https://svelte.dev"></iframe>
{/key}

Playground

Describe the proposed solution

Svelte should either switch to using Object.is for default equality or it should provide a way of supplying a custom equals function.

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions