-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: How is v5-alpha/beta? #2329
Comments
|
|
|
|
|
Maybe this ordering on "exports" can be changed for RN users of zustand ? |
@jacargentina let me take care of that |
@dbritto-dev I've solved it by configuring in config.resolver.unstable_conditionNames = ['require']; default is |
@jacargentina nice, I found that yesterday too but I didn't have time to answer any question. We shall add it to the docs. |
Does the readme of the v5 branch already reflect the changes that will be coming up in v5 or is there some other place where one could read about it? |
Thanks for reporting. |
I will create an example later. I can first describe how I encountered this problem. I first migrated from redux toolkit to zustand^4 and everything worked fine. The reason for this problem may be that Redux useSelector's callback do'not need to be wrapped by useCallback. After #2395, which may have caused the issue. Maybe useSyncExternalStoreWithSelector would be more suitable? |
https://stackblitz.com/edit/vitejs-vite-qvlgmz?file=src%2Fcomponents%2FTodolist.tsx @dai-shi I have create a todo list demo with this bug. The reason why it fails is because of the use of the useTodoFindIds function. Of course, the actual scenario is more complicated than what is written here. I want to find a set of data and then return their IDs. I'm not sure if some best practices were violated that caused this problem? |
Yes, you create a new reference every time in your selector function. // an easy reproduction
const useFooStore = create((set) => ({
todos: [],
}))
// this will cause an infinite loop because of new reference every render
useFooStore((state) => state.todos.map((todo) => todo.id)) To resolve it, either use This infinite-loop behavior can happen without Zustand, and Zustand follows the same behavior. |
@flq yeah, I'll add it. btw, they talk about memoizing selectors. |
FYI, proxy-memoize also works. https://redux.js.org/usage/deriving-data-selectors#proxy-memoize |
https://www.npmjs.com/package/zustand/v/5.0.0-beta.0 is published! Migration Guide: https://github.com/pmndrs/zustand/blob/v5/docs/guides/migrating-to-v5.mdx |
May post a reproduction when I find the time, but as a general note, I've been getting a ton of
and
errors after migrating from the latest version of v4 to v5 beta EDIT: Found the cause
|
Also ran into the same error when combing Zustand with proxy-memoize v3 that didn't occur before. Not exactly sure how to solve this one.
|
That sounds unexpected. Can you create a small reproduction with stackblitz? |
https://stackblitz.com/edit/vitejs-vite-ob9acn?file=src%2FApp.tsx |
Thanks. Now I get it. It the usage issue of proxy-memoze. By default, In other words, zustand v5 reveals the issue which was hidden in v4, and with the new one, it performs better. |
Zustand v5 is being developed #2138 and some alpha versions have been published.
We need more feedback before going beta, and releasing it finally.
npm i zustand@next
Please add reactions to this issue:
馃憤 : I tested v5-alpha in my project and it works fine.
馃憥 : I tested v5-alpha in my project and it fails. < Comment below!
馃憖 : I'm going to try it ASAP.
The text was updated successfully, but these errors were encountered: