Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1655

Bind to imported $state in svelte5 (error "constant_binding")

$
0
0
// states.svelte.jsexport let name = $state("John"); // a state to be shared by multiple components
<!-- Component.svelte --><script>  import { name } from "./states.svelte.js";</script><p>Hello, my name is <input type="text" bind:value={name} /></p>

REPL

When migrating to svelte5, I try to replace a writable store with a $state, but get error Cannot bind to import (https://svelte.dev/e/constant_binding).

What's the correct way to do it?


Viewing all articles
Browse latest Browse all 1655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>