Skip to content
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

Change proxy's value but proxyWithComputed's computed value doesn't change #435

Closed
ahaoboy opened this issue Apr 17, 2022 · 3 comments · Fixed by #436
Closed

Change proxy's value but proxyWithComputed's computed value doesn't change #435

ahaoboy opened this issue Apr 17, 2022 · 3 comments · Fixed by #436

Comments

@ahaoboy
Copy link
Contributor

ahaoboy commented Apr 17, 2022

https://stackblitz.com/edit/vitejs-vite-1zhh5q?file=src/App.tsx&terminal=dev

For updates correctly, I need to read data.length

const state: { data: string[]; filter: string } = {
  data: [],
  filter: '',
};
const store = proxyWithComputed(state, {
  todos(s) {
    // If access data.length, it works
    // if (!s.filter && s.data.length) return s.data;
    if (!s.filter) return s.data;
    return s.data.filter((i) => !i.includes(s.filter));
  },
});
@dai-shi
Copy link
Member

dai-shi commented Apr 17, 2022

Thanks for reporting. Looks like a bug that only happens with useSnapshot and computed object value.

@dai-shi
Copy link
Member

dai-shi commented Apr 17, 2022

Hi, would you try #436?
https://ci.codesandbox.io/status/pmndrs/valtio/pr/436
Find "Local Install Instruction" ☝️

@ahaoboy
Copy link
Contributor Author

ahaoboy commented Apr 17, 2022

Hi, would you try #436? https://ci.codesandbox.io/status/pmndrs/valtio/pr/436 Find "Local Install Instruction" ☝️

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants