Closed
Description
Describe the bug
A dependency seems to not be tracked correctly in certain scenarios.
The example uses a $derived.by
to destructure props from a stateful object updated via $effect
.
Reproduction
<script>
import { useData } from './data.svelte.js';
const { data, next } = $derived.by(useData);
</script>
<button onclick={() => next()}>
Next
</button>
<pre>{JSON.stringify(data, null, 2)}</pre>
// data.svelte.js
export function useData() {
let data = $state(null);
let i = $state(1);
$effect(() => {
fetchData(i);
async function fetchData(index) {
const res = await fetch(`https://dummyjson.com/posts/${index}`);
const json = await res.json();
data = json;
}
});
return {
get data() {
return data;
},
next() { i++; },
}
}
The data
updates initially, but changing the index does not re-trigger past v247.
Logs
No response
System Info
REPL
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels