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

【bug】createUseStorageState连续多次setState(pre => xx)的表现和 useState 的不一致 #2389

Open
Damon0820 opened this issue Dec 5, 2023 · 0 comments · May be fixed by #2082 or #2390
Open

Comments

@Damon0820
Copy link

Damon0820 commented Dec 5, 2023

问题

连续多次调用 createUseStorageState 的 setState(pre => xx),期望 pre 是上次的值,这个期望和 useState 的 setState 表现是一致的。目前通过下面示例发现,连续多次调用 createUseStorageState 的 setState(pre => xx),pre的值都是当前重新渲染时的快照,而非上次 setState 的值。demo链接:https://stackblitz.com/edit/stackblitz-starters-pwoao8?file=src%2FApp.tsx
image
image

@Damon0820 Damon0820 changed the title useStorage/Cookie的多次setState(pre => xx)表现和 useState 的不一致 【bug】useStorage/Cookie的多次setState(pre => xx)表现和 useState 的不一致 Dec 5, 2023
@Damon0820 Damon0820 changed the title 【bug】useStorage/Cookie的多次setState(pre => xx)表现和 useState 的不一致 【bug】createUseStorageState连续多次setState(pre => xx)的表现和 useState 的不一致 Dec 5, 2023
@liuyib liuyib linked a pull request Dec 6, 2023 that will close this issue
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant