73 Commits

Author SHA1 Message Date
Carsten Dietzel
827d5aacaf
Fix typo in prevent-rerenders-with-use-shallow.md (#2364) 2024-02-29 00:08:07 +09:00
Mohamed Yahye El Joud
08d13764ba
Update ssr-and-hydration.md (#2353)
* Update ssr-and-hydration.md

Small typo

* Update docs/guides/ssr-and-hydration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

---------

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
Co-authored-by: Blazej Sewera <code@sewera.dev>
2024-02-22 18:14:16 +09:00
Danilo Britto
8c1a1f0327
Update nextjs guide (#2328)
* Update nextjs guide

* Minor changes

* Minor changes

* Minor changes

* Minor changes

* Minor changes

* Minor changes
2024-02-16 11:58:13 +09:00
Charles Kornoelje
eb8443faa3
docs(middleware): modify both set and setState (#2306)
* docs(middleware): modify `set` and `setState`

* update middleware docs
2024-02-15 22:21:29 +09:00
Danilo Britto
b466a7585e
Update nextjs.md (#2324) 2024-02-10 09:14:38 +09:00
Alexander Densley
02ddd70d5b
fix broken link caused by typo (#2321) 2024-02-09 09:53:19 +09:00
Danilo Britto
f64a111b85
Update docs related to SSR/Hydration and SSR Apps (#2298)
* Update deprecation comments

* Update testing guide

* WIP

* Minor fixes

* WIP

* Update docs/guides/ssr-and-hygration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update docs/guides/ssr-and-hygration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* WIP

* Minor changes

* Minor changes

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update ssr-and-hygration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update ssr-and-hygration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update ssr-and-hygration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update ssr-and-hygration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update ssr-and-hygration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update ssr-and-hygration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update ssr-and-hygration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update ssr-and-hygration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update ssr-and-hygration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update docs/guides/nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update docs/guides/ssr-and-hygration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update docs/guides/nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Minor fixes

* Update docs/guides/nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update docs/guides/nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update docs/guides/ssr-and-hydration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update docs/guides/ssr-and-hydration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update docs/guides/ssr-and-hydration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update docs/guides/ssr-and-hydration.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update docs/guides/nextjs.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update docs/guides/nextjs.md

Co-authored-by: Charles Kornoelje <33156025+charkour@users.noreply.github.com>

* Update docs/guides/ssr-and-hydration.md

Co-authored-by: Charles Kornoelje <33156025+charkour@users.noreply.github.com>

* Update ssr-and-hydration.md

* Update docs/guides/ssr-and-hydration.md

Co-authored-by: Charles Kornoelje <33156025+charkour@users.noreply.github.com>

---------

Co-authored-by: Blazej Sewera <code@sewera.dev>
Co-authored-by: Charles Kornoelje <33156025+charkour@users.noreply.github.com>
2024-02-08 18:13:36 +09:00
Cody Partington
4be1e9eb4a
fix(docs): errors and types fix for URL state example (#2218)
* Update connect-to-state-with-url-hash.md

Resolved a few errors and type errors in the persist and create state with URL example:

1. createJsonStorage not being called in storageOptions resulting in a type error.
2. Correct hook not being exported
3. Moved the creation of initial state inline to get the correct types passed from create/persist.
4. Used state type as generic for persist.

* yarn prettier run

* Update docs/guides/connect-to-state-with-url-hash.md

Better name for state in setter

Co-authored-by: Danilo Britto <dbritto.dev@gmail.com>

* prettier run

---------

Co-authored-by: Danilo Britto <dbritto.dev@gmail.com>
Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
2023-12-31 22:29:34 +09:00
Andrew Hulterstrom
a4578fa5c4
docs: minor typo fix in flux-inspired-practice.md (#2252) 2023-12-15 09:08:06 +09:00
Charles Kornoelje
41838c5187
chore(docs): rewrite to remove deprecated references in persist docs (#2248)
* chore(docs): rewrite to remove deprecated references in persist docs

* chore(docs): remove deprecated equalityFn
2023-12-14 08:05:20 +09:00
Daishi Kato
9857a676a9
refactor: revisit prettier config to be minimal (#2193) 2023-11-14 12:19:51 +09:00
Rustam
c500f70cbb
fix(docs): add missing param in mocked create (Vitest guide) (#2166) 2023-11-01 23:25:51 +09:00
sobies93
13439986a8
Add missing parameter in mocking zustand testing guide (#2142)
It seems that the parameter was missing here, resulting in returning createUncurried instead of createUncurried(stateCreator)
2023-10-24 19:31:42 +09:00
Bram Van der Sype
643bb7ab11
Improve types in Immer middleware docs (#2139)
* Having the generic type on `immer` makes you lose introspection in IDE's.

* Add note about parenthesis and link back to typescript guide.
2023-10-23 08:44:10 +09:00
plrs9816
83b86a716c
fix(docs): support currying for testing mock (#2137)
* fix(docs): support currying for testing mock

* change function name

* fix lint error

* empty commit to trigger checks
2023-10-23 08:05:43 +09:00
Danilo Britto
602e1e9ebe
Update reset state docs (#2119)
* Update how-to-reset-state.md

* Minor changes

* Update how-to-reset-state.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update how-to-reset-state.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

---------

Co-authored-by: Blazej Sewera <code@sewera.dev>
2023-10-15 08:34:07 +09:00
Danilo Britto
e414f7ccf4
fix(shallow): Extract shallow vanilla and react (#2097)
* Update readmes

* Splitting shallow in two modules

* Update tests

* Minor changes

* Minor changes

* Rename shadow.tests.tsx to shallow.test.tsx

* Add new entrypoint for shallow/react

* Update structure

* Update shallow to export from vanilla and react

* Add vanilla/shallow and react/shallow entrypoints

* Update tests

* Update readmes

* Update src/shallow.ts

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>

* Minor changes

* Update readmes

* Update readmes

* Update tests

* Minor changes

---------

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
2023-10-05 23:04:56 +09:00
Danilo Britto
2be79c9154
Update testing docs (#2098)
* Update testing docs

* Minor changes

* Minor changes

* Minor changes

* Minor changes

* Minor changes

* Update docs/guides/testing.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

---------

Co-authored-by: Blazej Sewera <code@sewera.dev>
2023-10-05 08:17:28 +09:00
Daishi Kato
0504d4376a
chore(deps): update dev dependencies (#2093)
* chore(deps): update dev dependencies

* run prettier

* fix tsconfig

* fix workflow file
2023-10-02 22:28:51 +09:00
Fabrizio Vitale
3cbd468fe5
feat: add useShallow (#2090)
* feat: add useShallow

See
- https://github.com/pmndrs/zustand/discussions/1937
- https://github.com/pmndrs/zustand/discussions/1937#discussioncomment-7118242
- https://github.com/pmndrs/zustand/discussions/1937#discussioncomment-6974554

* chore(useShallow): improve unit tests

* chore(useShallow): PR feedback https://github.com/pmndrs/zustand/pull/2090#discussion_r1341963105

* fix(useShallow): tests not working on test_matrix (cjs, production, CI-MATRIX-NOSKIP)

* chore(useShallow): fix eslint warning issue (unused import)

* refactor(useShallow): simplify tests

* docs(useShallow): add guide

* fix(useShallow): prettier:ci error https://github.com/pmndrs/zustand/actions/runs/6369420511/job/17289749161?pr=2090

* docs(useShallow): update readme

* docs(useShallow): remove obsolete line from readme

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>

* doc(useShallow): PR feedback https://github.com/pmndrs/zustand/pull/2090#discussion_r1342120701

* docs(useShallow): small improvements of the useShallow guide

---------

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
2023-10-02 22:13:13 +09:00
Danilo Britto
f3a0fd802b
Update slices-pattern.md (#2046)
* Update slices-pattern.md

* Update typescript.md

* Fix format

* Update typescript.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Update typescript.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

---------

Co-authored-by: Blazej Sewera <code@sewera.dev>
2023-09-12 21:30:08 +09:00
Oshri Asulin
266e8641b2
fix: added 'create' and 'shallow' imports to docs (#2028)
* add missing import, change name store, change the func in app to two variables

* Update docs/guides/updating-state.md

---------

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
2023-09-10 09:13:56 +09:00
Danilo Britto
b8b5b636ce
Update jest codesandbox demo (#2022) 2023-09-02 08:51:06 +09:00
Danilo Britto
862c7bdd0f
Update testing docs (#2008)
* Update testing docs

* Minor fixes

* Minor fixes

* Update testing.md
2023-08-27 10:21:20 +09:00
John Gilliland
9ddfced2ea
docs: Update typescript guide persist examples... (#2001)
* docs: Update typescript guide persist examples to add required name option

* docs: run prettier

* docs: reverting prettier changes to testing.md

* docs: Update docs/guides/typescript.md per review comment.

Co-authored-by: Blazej Sewera <code@sewera.dev>

* docs: Update docs/guides/typescript.md per review comment and zustand conventions.

Co-authored-by: Blazej Sewera <code@sewera.dev>

* docs: change persist options name property to bearStore for consistency.

---------

Co-authored-by: John Gilliland <John.Gilliland@Starz.com>
Co-authored-by: Blazej Sewera <code@sewera.dev>
2023-08-25 16:54:04 +09:00
Michel Sabchuk
0058a03b78
fix(docs): Do not recommend deprecated useStore + equalityFn on initialize with props docs (#1997)
* Do not recommend deprecated useStore + equalityFn

* Show alternative without equality function

* Adjust content to be more clear

* Update docs/guides/initialize-state-with-props.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Apply prettier

---------

Co-authored-by: Blazej Sewera <code@sewera.dev>
2023-08-17 08:16:19 +09:00
Daishi Kato
5777a65cf5
chore(deps): update dev dependencies (#1965) 2023-08-01 10:42:18 +09:00
Tiago Bento
6d9c0cff0d
Fix slices-pattern.md link on flux-inspired-practice.md (#1962) 2023-07-28 09:39:58 +09:00
Mohammed 'Mo' Mulazada
f73736d59a
improve docs readability (#1931)
* make codeblock easier to understand

* add explanation to what mock does

* add info block

* rewrite typescript section

* Update typescript.md

* Update docs/guides/testing.md

Co-authored-by: Blazej Sewera <code@sewera.dev>

* prefix with >

---------

Co-authored-by: Blazej Sewera <code@sewera.dev>
2023-07-13 18:01:47 +09:00
Luiz Felicio
808a72225e
docs(auto-generating-selectors): Add vanilla store variant (#1915)
* Add variant for vanilla stores

* Update text tone and style

Co-authored-by: Blazej Sewera <code@sewera.dev>

* Adjust code style to match zustand's one

* Run prettier

---------

Co-authored-by: Blazej Sewera <code@sewera.dev>
2023-07-05 08:38:35 +09:00
Danilo Britto
1b557cba07
Testing docs minor fixes (#1898)
* Minor fixes

* Update testing.md

* Update testing.md
2023-06-28 08:07:11 +09:00
Danilo Britto
9333eb629c
Improve testing docs (#1875)
* Update testing docs (wip)

* WIP

* WIP

* Update testing docs

* Minor updates
2023-06-23 07:58:13 +09:00
Kiku
7276b531bc
docs: correct import alias syntax (#1889) 2023-06-21 20:01:30 +09:00
Chris K
e8597ae77f
docs: refine flux inspired docs to make pattern inspiration clearer (#1874)
* docs: refine flux inspired docs to make pattern inspiration clearer

* docs: remove the immutable note in the flux inspired docs
2023-06-18 11:42:01 +09:00
Celine Cheng
286e4436c7
docs: persist and connect state with url (#1804)
* docs: persist and connect state with url

* ran prettier

* remove line

* Apply suggestions from code review

Co-authored-by: Blazej Sewera <code@sewera.dev>

* from review comments

---------

Co-authored-by: celinecheng <celine.cheng@capitalone.com>
Co-authored-by: Blazej Sewera <code@sewera.dev>
2023-05-17 20:52:02 +09:00
Alex S
56ab6db790
docs: fixes typo on variable name (#1810) 2023-05-17 20:11:58 +09:00
Vadim Shvetsov
614bf5fbbb
Fix saving URL hash example demo (#1800) 2023-05-12 08:14:44 +09:00
Daniels L
e71e313bd7
docs(typescript): fix bounded use store example (#1779)
* test: changer

* docs: fix abstract bounded store hook TS example

Fixes type issues due to optional arg:
https://github.com/pmndrs/zustand/discussions/1564#discussioncomment-5735802

* fix: pr feedback
2023-04-28 17:40:42 +09:00
zc627788
df38aa8c5a
Fix document details (#1752)
export const useBoundStore = create((set) => ({
  count: 0,
  text: 'hello',
  inc: () => set((state) => ({ count: state.count + 1 })),
  setText: (text) => set({ text }),
})

example on this page is missing a trailing parenthesis
2023-04-17 11:01:56 +09:00
Danilo Britto
4c2c482820
fix(docs): update testing doc (#1739)
* Update formatting

* Update testing doc

* Fix formatting

* Minor changes

* Update testing doc
2023-04-07 20:49:00 +09:00
Jacob Weisenburger
f94ad23b43
fixes #1735 (#1737) 2023-04-07 11:54:45 +09:00
hellohy
baf9b309c1
fix(doc): update state-with-url-hash demo (#1687)
* fix(doc): update state-with-url-hash demo

* fix(doc): url-hash demo better code
2023-03-17 10:26:06 +09:00
Juanma Antonellini
de74f2e32d
fix(docs): Add Slices pattern example (#1485)
* Add Slices pattern example

By ading this example we can combine the real Slices pattern implementation (instead of multiple stores) with the resetAll method. Hope this helps! 😄

* Removed commetns and fixed typo

* Last PR changes
2023-02-28 10:56:30 +09:00
Aleksandar Dimitrov
38ccc1ffb1
Fix Jest example's usage of default imports (#1641)
* docs: Fix Jest example's usage of default imports

Default exports and imports are deprecated. The default import of `zustand` generates a deprecation warning on the console. The default export that was suggested previously would actually fail to compile. See the comments at the very bottom of #559 for further discussion.

This commit fixes the example in the documentation by introducing named exports & imports instead of default exports & imports.

* docs: Suggest using plain import for Jest

`jest.requireActual` is not necessary when we're not mocking any other
part of `zustand`.

* docs: Fix TypeScript example

The `create` function was curried where it should not have been.
The example is now written in plain TypeScript, as the code that it
contains does not require JSX.

* Prettier suggestions

* Use `jest.requireActual` to avoid circular dependencies
2023-02-27 10:58:11 +09:00
Devansh Jethmalani
f508b2c315
docs(typescript): clean up bounded useStore recipe (#1581)
* Make bounded useStore recipe section minimal

* Add a receipe for `createBoundedUseStore`

* run prettier

* use vanilla store
(as the react store is already a bounded useStore hook)
2023-01-30 08:23:26 +09:00
Holger Grosse-Plankermann
04080fdedc
fix(docs/typescript): provide example how to use middlewares with #1565 (#1578) 2023-01-27 09:00:31 +09:00
Holger Grosse-Plankermann
1023eb4af4
fix(docs/typescript): use correct initial state in test example (#1577) 2023-01-26 19:55:37 +09:00
Holger Grosse-Plankermann
44b23382f0
fix(docs/typescript): add typing usage with custom store hooks (#1565)
* Docs for discussion 1564

* Apply prettier

* fix(docs/typescript): use overloading example discussed in #1564
2023-01-25 11:52:53 +09:00
Yota Hada
1df4f6110e
docs: update testing (#1550) 2023-01-18 14:48:14 +09:00
Daishi Kato
0b55a3d74b
feat: deprecate default export (#1514) 2023-01-10 18:13:25 +09:00