Skip to content

Commit

Permalink
docs: responded to review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanRBrown committed Sep 2, 2024
1 parent 8837760 commit 2185141
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ const useBearStore = create(set => ({
nuts: 0,
honey: 0,
treats: {},
increaseNuts: () => set(state => ({ nuts: state.nuts + 1 })),
increaseHoney: () => set(state => ({ honey: state.honey + 1 })),
increaseTreats: (treat: string, count?: number) =>
set(state => ({ treats: { ...state.treats, [treat]: (state.treats[treat] ?? 0) + 1 } })),
...
}))

// Object pick, re-renders the component when either state.nuts or state.honey change
Expand All @@ -114,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 2185141

Please sign in to comment.