Am I doing something wrong? #343
Unanswered
darklight9811
asked this question in
Q&A
Replies: 1 comment
-
Hi @darklight9811, sorry for the delay! I wasn't getting notified for discussions, hopefully fixed now... It looks like the way you're pushing to the array is the problem: onClick={(e) => {
points.set((prev) => {
prev.push([e.pageX, e.pageY]);
return prev;
});
}} This pushes to the underling array instead of the observable, so it doesn't notify observers that it's changed. You can just push to the observable array. onClick={(e) => {
points.push([e.pageX, e.pageY]);
}} Legend-State data is mutable which works a bit differently than normal React hooks which require immutables. We have a section on the docs about that: https://legendapp.com/open-source/state/v3/usage/observable/#observables-are-mutable |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to make this work but its not reactive:
https://stackblitz.com/edit/vitejs-vite-ugxwsd
Beta Was this translation helpful? Give feedback.
All reactions