Skip to content

False positive non-state warning for bind:this #15640

@mquandalle

Description

@mquandalle

Describe the bug

If bind:this={ref} is used on an element inside a {#if reactiveState} block, the corresponding let ref declaration gets marked as "non-reactive-update" warning, which I believe is a false positive because the bind reference is still set and updated, and proxying it in $state doesn't change anything—except to remove the linter warning.

Previous issue on a similar topic #10435

Reproduction

https://svelte.dev/playground/ccd2e6f87d7e4985b5834547d4486aae?version=5.25.3

<script>
	let showDiv = $state();
	let divRef; // Warning: https://svelte.dev/e/non_reactive_update
</script>

{#if showDiv}
	<div bind:this={divRef}>Hello</div>
{/if}

System Info

Playground, svelte 5.25.3

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions