Fix Persist in TypeScript Usage on readme (#1193)

* Fix Persist example in Typescript

Persist middleware requires the name option to keep storage unique.

See https://github.com/pmndrs/zustand/blob/main/docs/persisting-store-data.md#name

This change adds the 'name' option to the Typescript Usage example to update it.
Additionally, the persist example already has this required option.

* run prettier on file
This commit is contained in:
Spencer Adolph 2022-08-17 19:15:59 -05:00 committed by GitHub
parent 75d0886cd6
commit f0b6023ece
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -461,10 +461,15 @@ interface BearState {
const useBearStore = create<BearState>()(
devtools(
persist((set) => ({
bears: 0,
increase: (by) => set((state) => ({ bears: state.bears + by })),
}))
persist(
(set) => ({
bears: 0,
increase: (by) => set((state) => ({ bears: state.bears + by })),
}),
{
name: 'bear-storage',
}
)
)
)
```