Skip to content

Commit

Permalink
Merge pull request #34 from chrisvander/readme-create-computed
Browse files Browse the repository at this point in the history
docs: update README.md
  • Loading branch information
chrisvander authored Aug 23, 2024
2 parents fd25426 + 49bdfb4 commit 3d89786
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ The middleware layer takes in your store creation function and a compute functio
```js
import { createComputed } from "zustand-computed"

const computeState = (state) => ({
const computeState = createComputed(state) => ({
countSq: state.count ** 2,
})
}))

const useStore = create(
computed(
Expand All @@ -38,8 +38,7 @@ const useStore = create(
// get() function has access to ComputedStore
square: () => set(() => ({ count: get().countSq })),
root: () => set((state) => ({ count: Math.floor(Math.sqrt(state.count)) })),
}),
computeState
})
)
)
```
Expand Down

0 comments on commit 3d89786

Please sign in to comment.