Comments (5)
To narrow this down more, if you simplify the code to do NOTHING.
const result = produce(appState, (draft) => {
console.log("woah")
});
You will still get an error
'getOwnPropertyDescriptor' on proxy: trap returned descriptor for property 'todos' that is incompatible with the existing property in the proxy target
at Function.entries (<anonymous>)
at freeze (immer.js?v=7cbabef2:168:12)
at maybeFreeze (immer.js?v=7cbabef2:333:5)
at finalize (immer.js?v=7cbabef2:277:5)
at processResult (immer.js?v=7cbabef2:255:14)
at Immer2.produce (immer.js?v=7cbabef2:551:16)
at HTMLButtonElement.onClick (+page.svelte:23:24)
at next (chunk-33KSVKAN.js?v=7cbabef2:346:14)
at chunk-33KSVKAN.js?v=7cbabef2:358:25
at yield_updates (chunk-7ZZEPC7R.js?v=7cbabef2:1868:12)
This does not happen if you remove $state
and make it a raw object
from svelte.
Looks like the solution is to use $state.snapshot
per the docs.
const result = produce($state.snapshot(appState), (draft) => {
console.log("woah")
});
You can close this unless action needs to be taken here
from svelte.
Since immer
is designed to handle immutable state, another possibility would be $state.frozen
, but it likely wouldn't work when trying to mutate top level properties of the object because it's frozen. Mhm..
from svelte.
It works with frozen, the whole point of immer
is to never modify objects at all but to replace them if anything changes.
from svelte.
Oh right, they're doing a proxy themselves etc.
Yeah, $state.frozen
is the way then - closing since there are ways to solve this.
from svelte.
Related Issues (20)
- Svelte 5: The `on` of `svelte/events` is restricted to use with `Element` only HOT 3
- Svelte 5: input value not updated during hydration
- Svelte 5: Customized built-in elements HOT 3
- svelte:head to allow ordering because meta tags are underneath script tags HOT 4
- Keyframes names scoped don't work correct in css nesting HOT 1
- TS EventHandler param type not matches HOT 2
- [email protected] breaks `svelte-check` HOT 1
- Svelte 5: snippets with multiple default values get incorrectly parsed
- Svelte 5: Syntax error on snippets with inline typing with optional properties HOT 3
- Svelte 5: compiler crash when using function in both event handler and markup
- Runes: Add an idiomatic way to clean up side-effects HOT 5
- Setting class $state property in constructor breaks all tracking HOT 15
- Inconsistent behavior of `let` directive in combination with snippets HOT 5
- Svelte 5: `<tr>` is invalid inside `<table>` HOT 2
- Svelte 5: hydration error on each with 0 elements on the server and some elements on the client
- Memory leak on component unmount HOT 1
- Svelte 5: post increment/decrement of proxy property is miscompiled HOT 1
- Svelte 5: How to fix svelte/internal which was a private module used by Svelte 4 components that no longer exists in Svelte 5 HOT 2
- Rename `legacy.componentApi` to `compatibility.classComponent` HOT 1
- enhancement(custom element): svelte 5 should automatically set converters based on types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte.