Skip to content

Fix repeated hydration in MobX example - #102702

Open
ashsajal1 wants to merge 2 commits into
vercel:canaryfrom
ashsajal1:gpt/mobx-hydration-rerenders
Open

ashsajal1 wants to merge 2 commits into
vercel:canaryfrom
ashsajal1:gpt/mobx-hydration-rerenders

Conversation

@ashsajal1

@ashsajal1 ashsajal1 commented Dec 2, 2026 •

Copy link
Copy Markdown

What

Fix repeated MobX store initialization and hydration issues in the with-mobx example.

  • Initialize the MobX store lazily using useState to preserve the same store instance across component rerenders.
  • Hydrate the existing store when initialState changes using useEffect.
  • Preserve client-side store updates during unrelated React rerenders.

Why

Previously, StoreProvider called initializeStore() on every render. This could recreate the MobX store and cause existing client-side state to be lost.

This fix addresses [#61320 — with mobx bug](#61320).

How to test

Added E2E coverage for the following scenarios:

  • Verify that the initial MobX state is correctly rendered during server-side rendering.
  • Update the store on the client and verify that the state persists across React rerenders.
  • Update the provider's initialState and verify that the existing store is hydrated with the new data.

@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

@ashsajal1 is attempting to run Vercel CI for a fork pull request of the Vercel Team on Vercel.

A member of the Team first needs to approve it.

@github-actions github-actions Bot added examples Issue was opened via the examples template. tests labels Dec 2, 2026
@ashsajal1
ashsajal1 marked this pull request as ready for review December 2, 2026 08:36

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples Issue was opened via the examples template. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant