-
Hi, export class Store {
public info = [{ status: "empty" }];
public loadAll = () => {
axios.get(url).then((x) => {
this.info = x.data;
});
};
} I can't make it work... Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Unfortunately, you seem to have some misconceptions with
Here's the fix, but I'd recommend to avoid using So, my recommendation is the following instead: export const state = proxy({
info: [{ status: "empty" }],
loadAll: () => {
axios.get(url).then((x) => {
state.info = x.data;
});
},
}); |
Beta Was this translation helpful? Give feedback.
Unfortunately, you seem to have some misconceptions with
this
behavior.Here's the fix, but I'd recommend to avoid using
this
.https://codesandbox.io/s/valtio-to-do-list-forked-7k7bn0?file=/src/App.tsx
So, my recommendation is the following instead: