Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
dbritto-dev committed Sep 3, 2024
2 parents 100dcb8 + 4ec7077 commit c16d52f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ concurrency:

jobs:
build:
uses: pmndrs/docs/.github/workflows/build.yml@v1
uses: pmndrs/docs/.github/workflows/build.yml@v2
with:
mdx: './docs'
mdx: 'docs'
libname: 'Zustand'
home_redirect: '/getting-started/introduction'
icon: '/favicon.ico'
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ nav: 0
---

<div class="flex justify-center mb-4">
<img src="https://github.com/pmndrs/zustand/raw/main/docs/bear.jpg" />
<img src="../bear.jpg" />
</div>

A small, fast, and scalable bearbones state management solution.
Expand Down
5 changes: 2 additions & 3 deletions docs/guides/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,8 @@ const bearStore = createStore<BearState>()((set) => ({
increase: (by) => set((state) => ({ bears: state.bears + by })),
}))

const createBoundedUseStore = ((store) => (selector) => useStore(store)) as <
S extends StoreApi<unknown>,
>(
const createBoundedUseStore = ((store) => (selector) =>
useStore(store, selector)) as <S extends StoreApi<unknown>>(
store: S,
) => {
(): ExtractState<S>
Expand Down
9 changes: 5 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ import { create } from 'zustand'
import { useShallow } from 'zustand/react/shallow'

const useBearStore = create((set) => ({
bears: 0,
increasePopulation: () => set((state) => ({ bears: state.bears + 1 })),
removeAllBears: () => set({ bears: 0 }),
nuts: 0,
honey: 0,
treats: {},
// ...
}))

// Object pick, re-renders the component when either state.nuts or state.honey change
Expand All @@ -110,7 +111,7 @@ const [nuts, honey] = useBearStore(
const treats = useBearStore(useShallow((state) => Object.keys(state.treats)))
```

For more control over re-rendering, you may provide any custom equality function.
For more control over re-rendering, you may provide any custom equality function (this example requires the use of [`createWithEqualityFn`](./docs/migrations/migrating-to-v5.md#using-custom-equality-functions-such-as-shallow)).

```jsx
const treats = useBearStore(
Expand Down

0 comments on commit c16d52f

Please sign in to comment.