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

Update docs content #2508

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
9b23d94
Move docs to old docs
dbritto-dev Apr 24, 2024
b92ba68
Add new docs (WIP)
dbritto-dev Apr 24, 2024
e1c081e
Minor changes
dbritto-dev Apr 24, 2024
8828d67
Minor changes
dbritto-dev Apr 24, 2024
54344d1
Minor fixes
dbritto-dev Apr 24, 2024
90c23c0
Minor fixes
dbritto-dev Apr 24, 2024
aafed40
Minor fixes
dbritto-dev Apr 24, 2024
3144ea8
Minor fixes
dbritto-dev Apr 24, 2024
f1a3834
Minor changes
dbritto-dev Apr 24, 2024
aeb7cde
Minor fixes
dbritto-dev Apr 24, 2024
6c07e5f
Minor fixes
dbritto-dev Apr 24, 2024
60846c7
Minor changes
dbritto-dev Apr 25, 2024
7bdf1cc
Minor changes
dbritto-dev Apr 25, 2024
a4ab750
Minor changes
dbritto-dev Apr 25, 2024
1606977
Minor changes
dbritto-dev Apr 25, 2024
df190b9
Minor changes
dbritto-dev Apr 25, 2024
a5ceba7
Minor changes
dbritto-dev Apr 25, 2024
3637fe7
Minor fixes
dbritto-dev Apr 25, 2024
0746ab1
WIP
dbritto-dev Apr 25, 2024
adec185
Minor changes
dbritto-dev Apr 25, 2024
ee07ba5
WIP
dbritto-dev Apr 27, 2024
626e972
Merge branch 'main' of github.com:dbritto-dev/zustand into update-doc…
dbritto-dev Apr 27, 2024
89771e5
WIP
dbritto-dev Apr 28, 2024
72fec5c
WIP
dbritto-dev Apr 30, 2024
b1f84f8
WIP
dbritto-dev Apr 30, 2024
c4322c5
WIP
dbritto-dev Apr 30, 2024
5834bbf
WIP
dbritto-dev May 3, 2024
cdba318
WIP
dbritto-dev May 4, 2024
ac441ae
WIP
dbritto-dev May 6, 2024
aea4a45
WIP
dbritto-dev May 6, 2024
479da65
WIP
dbritto-dev May 9, 2024
135bc69
WIP
dbritto-dev May 16, 2024
17d433d
WIP
dbritto-dev May 31, 2024
c542900
WIP
dbritto-dev May 31, 2024
c3998cb
Update docs/reference/use-shallow.md
dbritto-dev Jun 2, 2024
27d8afd
Update docs/reference/create-with-equality-fn.md
dbritto-dev Jun 2, 2024
3322bea
WIP
dbritto-dev Jun 2, 2024
32d4be1
Merge branch 'main' of github.com:pmndrs/zustand into update-docs-con…
dbritto-dev Jun 2, 2024
6bd2963
Merge branch 'main' of github.com:pmndrs/zustand into update-docs-con…
dbritto-dev Jun 12, 2024
370dfab
WIP
dbritto-dev Jun 12, 2024
fc886f1
WIP
dbritto-dev Jun 13, 2024
e8cfb2d
WIP
dbritto-dev Jul 15, 2024
9daa0b8
WIP
dbritto-dev Jul 16, 2024
57c2ff3
WIP
dbritto-dev Jul 27, 2024
fdbfb0e
WIP
dbritto-dev Jul 27, 2024
ba484ce
Merge branch 'main' of github.com:pmndrs/zustand into update-docs-con…
dbritto-dev Jul 27, 2024
f2d33dd
WIP
dbritto-dev Aug 4, 2024
001f243
Merge branch 'main' of github.com:pmndrs/zustand into update-docs-con…
dbritto-dev Aug 4, 2024
4593bf0
WIP
dbritto-dev Aug 7, 2024
20af30d
Merge branch 'main' of github.com:pmndrs/zustand into update-docs-con…
dbritto-dev Aug 9, 2024
5c748b7
WIP
dbritto-dev Aug 10, 2024
5675bef
WIP
dbritto-dev Aug 14, 2024
5da8d0e
WIP
dbritto-dev Aug 14, 2024
e49b0d0
WIP
dbritto-dev Aug 24, 2024
c8e16b9
WIP
dbritto-dev Aug 25, 2024
d15ea77
Merge branch 'main' of github.com:pmndrs/zustand into update-docs-con…
dbritto-dev Aug 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/community/docs-contributors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Docs Contributors
description:
nav: 301
---
5 changes: 5 additions & 0 deletions docs/community/third-party-libraries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Third-party Libraries
description:
nav: 302
---
5 changes: 5 additions & 0 deletions docs/community/versioning-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Versioning Policy
description:
nav: 303
---
5 changes: 5 additions & 0 deletions docs/community/zustand-videos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Zustand Videos
description:
nav: 300
---
5 changes: 5 additions & 0 deletions docs/learn/async-data-and-data-fetching.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Async Data and Data Fetching
description:
nav: 106
---
5 changes: 5 additions & 0 deletions docs/learn/choosing-the-state-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Choosing the State Structure
description: One store, multiple stores, and multiple slices
nav: 104
---
5 changes: 5 additions & 0 deletions docs/learn/colocation-actions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Colocating Actions
description:
nav: 105
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Extracting State Logic into a Reducer with Redux and Devtools Middlewares
description:
nav: 112
---
5 changes: 5 additions & 0 deletions docs/learn/isolating-state-between-components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Isolating State Between Components
description:
nav: 108
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Listening to Selected Data with SubscribeWithSelector Middleware
description:
nav: 113
---
5 changes: 5 additions & 0 deletions docs/learn/middleware-use-cases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Middleware Use Cases
description:
nav: 114
---
Empty file added docs/learn/nextjs.md
Empty file.
5 changes: 5 additions & 0 deletions docs/learn/persisting-state-with-persist-middleware.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Persisting State with Persist Middleware
description:
nav: 111
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Selecting Data and Preventing Re-renders with selectors and equality function
description:
nav: 107
---
5 changes: 5 additions & 0 deletions docs/learn/start-new-project.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Start a new project
description: Vanilla, React, and React Native
nav: 102
---
Empty file added docs/learn/testing.md
Empty file.
5 changes: 5 additions & 0 deletions docs/learn/thinking-in-zustand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Thinking in Zustand
description: Motivation, principles, and glossary
nav: 101
---
5 changes: 5 additions & 0 deletions docs/learn/tutorial-tic-tac-toe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: 'Tutorial: Tic-Tac-Toe'
description:
nav: 100
---
5 changes: 5 additions & 0 deletions docs/learn/using-middlewares.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Using Middlewares
description:
nav: 109
---
5 changes: 5 additions & 0 deletions docs/learn/using-typescript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Using TypeScript
description:
nav: 103
---
5 changes: 5 additions & 0 deletions docs/learn/writing-immutable-update-with-immer-middleware.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Writing Immutable Updates with Immer Middleware
description:
nav: 110
---
98 changes: 98 additions & 0 deletions docs/reference/combine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
title: combine
description:
nav: 201
---

# combine

`combine` middleware lets you create a new state by combining an initial state with additional
state created by a function. This middleware is particularly useful due to infers the state, so you
don't need to type it.

```js
combine(initialState, additionalStateCreator)
```

- [Reference](#reference)
- [Signature](#combine-signature)
- [`setState` function](#setstate-function)
- [`getState` function](#getstate-function)
- [`subscribe` function](#subscribe-function)
- [`storeApi`](#storeapi)
- [Usage](#usage)
- [Troubleshooting](#troubleshooting)

## Reference

### `combine` Signature

```ts
combine<T, U>(initialState: T, additionalStateCreatorFn: StateCreator<T, [], [], U>): StateCreator<Omit<T, keyof U> & U, [], []>
```

#### Parameters

- `initialState`: The value you want the state to be initially. It can be a value of any type,
except a function.
- `additionalStateCreatorFn`: The state creator function that specifies how the state gets
initialized and updated. It must be pure, should take `setState` function, `getState` function
and `storeApi` as arguments.

#### Returns

`combine` returns a state creator function.

### `setState` function

The `setState` function lets you update the state to a different value and trigger re-render. You
can pass the next state directly, a next partial state, a function that calculates it from the
previous state, or replace it completely.

#### Parameters

- `nextState`: The value that you want the state to be. It can be a value of any type, but there is
a special behavior for functions.
- If you pass an object as a `nextState`. It will shallow merge `nextState` with the current
state. You can pass only the properties you want to update, this allows for selective state
updates without modifying other properties.
- If you pass a non-object as a `nextState`, make sure you use `replace` as `true` to avoid
unexpected behaviors.
- If you pass a function as a `nextState`. It must be pure, should take current state as its
only argument, and should return the next state. The next state returned by the updater
function face the same restrictions of any next state.
- `replace`: This optional boolean flag controls whether to replace the entire state or merge the
update with the current state.

#### Returns

`setState` function do not have a return value.

### `getState` function

The `getState` function lets you access to the current state. It can be stale on asynchronous
operations.

### `subscribe` function

The `subscribe` function lets you subscribe to state updates. It should take current state and
previous state as arguments.

#### Parameters

- `currentState`: The current state.
- `previousState`: The previous state.

#### Returns

`subscribe` returns a function that lets you unsubscribe.

### `storeApi`

The `storeApi` lets you access to the store API functions like
[`setState` function](#setstate-function), [`getState` function](#getstate-function), and
[`subscribe` function](#subscribe-function).

## Usage

## Troubleshooting
71 changes: 71 additions & 0 deletions docs/reference/core-concepts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
title: Core Concepts
description:
nav: 200
---

# Core Concepts

## Store

The Store lets you access to the store API utilities.

## API Utilities

These store API utilities are: `setState` function, `getState` function, and `subscribe` function.

### `setState` function

The `setState` function lets you update the state to a different value and trigger re-render. You
can pass the next state directly, a next partial state, a function that calculates it from the
previous state, or replace it completely.

#### Parameters

- `nextState`: The value that you want the state to be. It can be a value of any type, but there is
a special behavior for functions.
- If you pass an object as a `nextState`. It will shallow merge `nextState` with the current
state. You can pass only the properties you want to update, this allows for selective state
updates without modifying other properties.
- If you pass a non-object as a `nextState`, make sure you use `replace` as `true` to avoid
unexpected behaviors.
- If you pass a function as a `nextState`. It must be pure, should take current state as its
only argument, and should return the next state. The next state returned by the updater
function face the same restrictions of any next state.
- `replace`: This optional boolean flag controls whether the state is completely replaced or only
shallow updated, through a shallow merge.

#### Returns

`setState` function do not have a return value.

### `getState` function

The `getState` function lets you access to the current state. It can be stale on asynchronous
operations.

### `subscribe` function

The `subscribe` function lets you subscribe to state updates. It should take current state, and
its previous state as arguments.

#### Parameters

- `currentState`: The current state.
- `previousState`: The previous state.

#### Returns

`subscribe` returns a function that lets you unsubscribe from itself.

### Selector

Lorem, ipsum dolor sit amet consectetur adipisicing elit. Vel veritatis alias saepe vitae placeat
blanditiis laborum, asperiores architecto explicabo unde. Cum sint vero veritatis. Hic ipsum quis
saepe voluptates temporibus!

### Bound Hook

Lorem, ipsum dolor sit amet consectetur adipisicing elit. Minus quas sequi, similique corrupti iure
incidunt autem. Voluptas eum atque harum! Assumenda natus, animi doloribus facilis maiores dicta
iusto ipsa earum.
Loading
Loading