-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
overwrapping proxies #19
Comments
upon second thought, solid does this:
this whole shallow-merging is something I dislike the most from solid's store api, so I wouldn't recommend repeating it. instead I would propose the opposite API:
makes a reference to store.nodes, so that whenever u do p.ex when doing
it would unwrap store.nodes[0] (afaik unwrap does not exist yet in deepsignal, but it would be a great addition.. I guess it's the same as |
Good catch. I've just opened a PR to fix it: #20 |
Released as [email protected]. @bigmistqke could you please test it out and see if everything works as expected now? |
Ok so I believe the crashing has somehow something to do with Still not capable to create a minimal reproduction. When I test it out with less complex state it's all working fine. |
If you can reproduce it and share a Stackblitz with me, that would be really helpful. Thanks. |
I would like to, but can not seem to get deepsignal to work with stackblitz/codesandbox: |
Okay I think I found the culprit. I had added a deepSignal in The weird thing is it even broke computed in this crashesimport { computed } from '@preact/signals-react';
import { deepSignal } from 'deepsignal';
const store = deepSignal({});
const rows = computed(() => [''].map(() => <></>);
const App = () => {
return rows;
} this does not crashimport { computed } from '@preact/signals-react';
const rows = computed(() => [''].map(() => <></>);
const App = () => {
return rows;
} My other store is in a seperate file and that one seems to be working fine. It's an unrelated issue to the update, as it also happens when I revert the package to |
For React, you should use:
Maybe there's a problem with imports without modules. It works fine here: |
o no lol. you are right, was a typo, in the store I properly import it. Thanks for the support! |
I can't spot any differences between
Please, do. Thanks! |
Hi luisherranz
First of all thank u for the nice library.
Is the smoothest state management dx in react imo. Dangerously smooth!
I came across a bit of an unpleasantry in dx with what looks like stale state, caused by unwanted nesting of the proxy-state.
Say I have the following store
if I would do
store.renderedNode would become a nested proxy.
accessing and mutating this proxy would cause inconsistent state, I assume because the outer-proxy consumes all the mutations.
It is possible to prevent this bug by doing
But I wonder if it would be possible to prevent this overwrapping/unwanted nesting automatically, p.ex by checking for a symbol on the proxy.
I think solidjs does something similar with their createStore.
The text was updated successfully, but these errors were encountered: