Open
Description
Describe the bug
When initializing the tweened
store with a derived value, I get a warning: "State referenced in its own scope will never update. Did you mean to reference it inside a closure?"
Seems like a false positive to me, though I could be missing something. I want to initialize the tweened store to the initial value of the derived expression. I could duplicate the logic, but would rather avoid if possible.
Expected behavior: no warning is shown
<script>
import { tweened } from 'svelte/motion';
let count = $state(1);
let doubled = $derived(count * 2);
let tweenedDouble = tweened(doubled);
$effect(() => {
tweenedDouble.set(doubled);
})
function increment() {
count += 1;
}
</script>
<p>{$tweenedDouble.toFixed(2)}</p>
<button onclick={increment}>
clicks: {count}
</button>
Reproduction
Logs
n/a
System Info
REPL
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels