Skip to content

docs: add useState vanilla store instantiation examples#3319

Merged
dai-shi merged 3 commits intopmndrs:mainfrom
oleksandr-danylchenko:unify-vanilla-store-definition
Dec 10, 2025
Merged

docs: add useState vanilla store instantiation examples#3319
dai-shi merged 3 commits intopmndrs:mainfrom
oleksandr-danylchenko:unify-vanilla-store-definition

Conversation

@oleksandr-danylchenko
Copy link
Copy Markdown
Contributor

@oleksandr-danylchenko oleksandr-danylchenko commented Dec 9, 2025

Related Bug Reports or Discussions

#3318

Summary

I updated the vanilla store instantiation examples using the newer useState pattern:

Before After
const storeRef = useRef(null);
if (storeRef.current === null) {
  storeRef.current = createBearStore();
}
const store = storeRef.current;
const [store] = useState(createBearStore);

A need for such a change was expressed in #3318 due to the inconsistent vanilla store declaration pattern across the docs.

@dai-shi and @dbritto-dev expressed that using the useState pattern would be a clearer recommendation for the consumers.

Check List

  • pnpm run fix for formatting and linting code and docs

@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 9, 2025

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

Project Deployment Preview Comments Updated (UTC)
zustand-demo Ready Ready Preview Comment Dec 10, 2025 8:17am

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci Bot commented Dec 9, 2025

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.

Comment thread docs/previous-versions/zustand-v3-create-context.md
@dai-shi dai-shi requested a review from dbritto-dev December 9, 2025 14:10
Comment thread docs/guides/initialize-state-with-props.md Outdated
Comment thread docs/guides/testing.md Outdated
Comment thread docs/guides/testing.md Outdated
Comment thread docs/guides/nextjs.md Outdated
Copy link
Copy Markdown
Collaborator

@dbritto-dev dbritto-dev left a comment

Choose a reason for hiding this comment

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

LGTM

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Dec 9, 2025

commit: d194489

@dbritto-dev
Copy link
Copy Markdown
Collaborator

@oleksandr-danylchenko please run pnpm run fix we need to fix the lint

@dai-shi dai-shi merged commit a124d59 into pmndrs:main Dec 10, 2025
32 checks passed
@oleksandr-danylchenko oleksandr-danylchenko deleted the unify-vanilla-store-definition branch December 10, 2025 10:25
mergify Bot added a commit to robfrank/linklift that referenced this pull request Jan 18, 2026
Bumps [zustand](https://github.com/pmndrs/zustand) from 5.0.9 to 5.0.10.
Release notes

*Sourced from [zustand's releases](https://github.com/pmndrs/zustand/releases).*

> v5.0.10
> -------
>
> This version includes a fix to the `persist` middleware for an edge case.
>
> What's Changed
> --------------
>
> * fix(persist): prevent race condition during concurrent rehydrate calls by [`@​Niyaz-Mazhitov`](https://github.com/Niyaz-Mazhitov) in [pmndrs/zustand#3336](https://redirect.github.com/pmndrs/zustand/pull/3336)
>
> New Contributors
> ----------------
>
> * [`@​max-programming`](https://github.com/max-programming) made their first contribution in [pmndrs/zustand#3310](https://redirect.github.com/pmndrs/zustand/pull/3310)
> * [`@​oleksandr-danylchenko`](https://github.com/oleksandr-danylchenko) made their first contribution in [pmndrs/zustand#3319](https://redirect.github.com/pmndrs/zustand/pull/3319)
> * [`@​MateuszSobiech`](https://github.com/MateuszSobiech) made their first contribution in [pmndrs/zustand#3334](https://redirect.github.com/pmndrs/zustand/pull/3334)
> * [`@​EduardoRangelG`](https://github.com/EduardoRangelG) made their first contribution in [pmndrs/zustand#3326](https://redirect.github.com/pmndrs/zustand/pull/3326)
> * [`@​1mehdifaraji`](https://github.com/1mehdifaraji) made their first contribution in [pmndrs/zustand#3339](https://redirect.github.com/pmndrs/zustand/pull/3339)
> * [`@​kamja44`](https://github.com/kamja44) made their first contribution in [pmndrs/zustand#3349](https://redirect.github.com/pmndrs/zustand/pull/3349)
> * [`@​Niyaz-Mazhitov`](https://github.com/Niyaz-Mazhitov) made their first contribution in [pmndrs/zustand#3336](https://redirect.github.com/pmndrs/zustand/pull/3336)
>
> **Full Changelog**: <pmndrs/zustand@v5.0.9...v5.0.10>


Commits

* [`003b0a7`](pmndrs/zustand@003b0a7) 5.0.10
* [`9bb7f3b`](pmndrs/zustand@9bb7f3b) chore(deps): update dev dependencies ([#3353](https://redirect.github.com/pmndrs/zustand/issues/3353))
* [`d0cb549`](pmndrs/zustand@d0cb549) fix(persist): prevent race condition during concurrent rehydrate calls ([#3336](https://redirect.github.com/pmndrs/zustand/issues/3336))
* [`59e8783`](pmndrs/zustand@59e8783) test: remove eslint-disable for no-unused-expressions ([#3349](https://redirect.github.com/pmndrs/zustand/issues/3349))
* [`db6fe66`](pmndrs/zustand@db6fe66) docs(CONTRIBUTING): fix 'npm install' to 'pnpm install' ([#3350](https://redirect.github.com/pmndrs/zustand/issues/3350))
* [`8f1d45a`](pmndrs/zustand@8f1d45a) Fix formatting and punctuation in third-party libraries doc ([#3346](https://redirect.github.com/pmndrs/zustand/issues/3346))
* [`74d0aec`](pmndrs/zustand@74d0aec) Add zustand-mutable middleware link ([#3343](https://redirect.github.com/pmndrs/zustand/issues/3343))
* [`f912630`](pmndrs/zustand@f912630) Add zustand-mmkv-storage to third-party libraries ([#3339](https://redirect.github.com/pmndrs/zustand/issues/3339))
* [`4f1f963`](pmndrs/zustand@4f1f963) docs: add memoized selector usage with `useStore` ([#3320](https://redirect.github.com/pmndrs/zustand/issues/3320))
* [`aa2da00`](pmndrs/zustand@aa2da00) docs: fix navigation order for comparison and tutorial markdowns ([#3326](https://redirect.github.com/pmndrs/zustand/issues/3326))
* Additional commits viewable in [compare view](pmndrs/zustand@v5.0.9...v5.0.10)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=zustand&package-manager=npm\_and\_yarn&previous-version=5.0.9&new-version=5.0.10)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
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