Skip to content

Commit

Permalink
fix: added 'create' and 'shallow' imports to docs (#2028)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
OshriAsulin and dai-shi authored Sep 10, 2023
1 parent 5062de1 commit 266e864
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/guides/updating-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ the new state, and it will be shallowly merged with the existing state in the
store. **Note** See next section for nested state.

```tsx
import { create } from 'zustand'

type State = {
firstName: string
lastName: string
Expand All @@ -21,7 +23,7 @@ type Action = {
}

// Create your store, which includes both state and (optionally) actions
const useStore = create<State & Action>((set) => ({
const usePersonStore = create<State & Action>((set) => ({
firstName: '',
lastName: '',
updateFirstName: (firstName) => set(() => ({ firstName: firstName })),
Expand All @@ -32,10 +34,8 @@ const useStore = create<State & Action>((set) => ({
function App() {
// "select" the needed state and actions, in this case, the firstName value
// and the action updateFirstName
const [firstName, updateFirstName] = useStore(
(state) => [state.firstName, state.updateFirstName],
shallow
)
const firstName = usePersonStore((state) => state.firstName)
const updateFirstName = usePersonStore((state) => state.updateFirstName)

return (
<main>
Expand Down

1 comment on commit 266e864

@vercel
Copy link

@vercel vercel bot commented on 266e864 Sep 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.