-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
proxy set handler returned false for property "'toast'" #204
Comments
Hey, thanks for trying the library!
export const store = proxy<IStore>({
toast: {
success: null,
error: null,
open: false,
},
resetToast: () => {
store.toast = {
success: null,
error: null,
open: false,
};
},
}); |
This is not the first time the error message confuses people. #178 I understand the problem is serious.
I'd like to ask for volunteers. |
I wouldn't mind going through both the recommendations and let you know what my thinking of this is |
@dai-shi I wouldn't mind playing around with option (1). I think it's a better approach than Option (2) personally both in ease of implementation and practicality (we can't guarantee that someone is running a great & fully functioning linting config) I'll get back with feedback in the next day or two if nobody gets there before me. |
@israelidanny I gave up option 1 in a nice way, so it might require some tricks. One thing to note is we don't want to modify proxy-compare for valtio-only problems. @barelyhuman So, would you primarily take option 2? I appreciate your helps. Please also refer discussions in #178. |
This was confusing to say the least. The error was pointing to the store. But it was my fault. const snap = useSnapshot(store);
snap.resetToast(); After that fix. It's been working great. |
If one prefers using store.resetToast(); Another discussion in #205. |
I made the change. Now I'm using |
There is the option of binding all the methods to the correct |
While that would help with the developer experience but then we start assuming what the developer wants, someone might use this inside a function and expect As in, context of There can definitely be better solutions , i'm open to any. Since I've only written like 2-3 lines on the eslint plugin as of now |
The current behavior is intentional to make it as pure JS as possible.
const state = proxy({
count: 1,
getDoubledCount() {
return this.count * 2
},
})
console.log(state.getDoubledCount())
const Component = () => {
const snap = useSnapshot(state)
return <div>{snap.getDoubledCount()}</div>
} This doesn't work if we bind |
option 2 is merged. So, let me close this. @israelidanny Let us know if you are still working on this. |
The text was updated successfully, but these errors were encountered: