-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Description
Describe the bug
If $state contains nested objects (that passes prototype === object_prototype) and they are mutated outside of $effect (?) and accessed, $derived doesn't return the latest value.
class {
data = $state<{ position: { x: number }>();
position = $derived(this.data?.position);
}Reproduction
sorry for the messy repro. this is the simplest I could get it to.
data.name and name correctly returns 1
data.position.x correctly returns 1
position returns undefined
this happens only if position is accessed outside of an $effect.active() (?).
comment out this.content.map(e => e.position); in models.svelte.ts line 36, and position then correctly returns 1
Logs
No response
System Info
System:
OS: macOS 14.2.1
CPU: (8) arm64 Apple M1
Memory: 102.20 MB / 8.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
Yarn: 1.22.21 - ~/.nvm/versions/node/v18.19.0/bin/yarn
npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
pnpm: 8.6.12 - ~/.nvm/versions/node/v18.19.0/bin/pnpm
bun: 1.0.15 - ~/.bun/bin/bun
Watchman: 2023.12.04.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 123.0.6312.59
Safari: 17.2.1
npmPackages:
rollup: ^4.9.5 => 4.13.0Severity
blocking all usage of svelte
Metadata
Metadata
Assignees
Labels
No labels