Skip to content

fix(persist): use latest state in post-rehydration callback#3391

Open
Shohjahon-n wants to merge 4 commits intopmndrs:mainfrom
Shohjahon-n:fix-persist-latest-postrehydration-state
Open

fix(persist): use latest state in post-rehydration callback#3391
Shohjahon-n wants to merge 4 commits intopmndrs:mainfrom
Shohjahon-n:fix-persist-latest-postrehydration-state

Conversation

@Shohjahon-n
Copy link

Related Bug Reports or Discussions

Fixes #

Summary

  • Use current store state (get()) for the post-rehydration callback in async hydration flow.
  • Prevent stale callback payload when state changes again during hydration.
  • Add an async regression test that mutates state during hydration and verifies callback receives the latest merged state.

Check List

  • pnpm run fix for formatting and linting code and docs

Pass current store state to post-rehydration callback to avoid stale values after hydration-triggered updates.

Add async persist regression test that updates state during hydration and asserts callback receives latest state.
@vercel
Copy link

vercel bot commented Feb 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
zustand-demo Ready Ready Preview, Comment Mar 5, 2026 2:42am

Request Review

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 22, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on it. Let's take time to discuss when we should land this.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 5, 2026

commit: 8d2149f

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 this pull request may close these issues.

3 participants