mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
Update persist documentation for storage (#1521)
This replaces `getStorage` with `storage`. This PR raises two questions: - Should we write documentation on how to migrate from the `getStorage` API to the `storage` API? - Should we version the middleware separately from the zustand core?
This commit is contained in:
parent
820dbd35ea
commit
86c5016e28
@ -300,7 +300,7 @@ Or even to change the storage engine:
|
||||
|
||||
```ts
|
||||
useBoundStore.persist.setOptions({
|
||||
getStorage: () => sessionStorage,
|
||||
storage: createJSONStorage(() => sessionStorage),
|
||||
})
|
||||
```
|
||||
|
||||
@ -511,7 +511,7 @@ export const useBoundStore = create(
|
||||
}),
|
||||
{
|
||||
name: 'food-storage', // unique name
|
||||
getStorage: () => storage,
|
||||
storage: createJSONStorage(() => storage),
|
||||
}
|
||||
)
|
||||
)
|
||||
@ -565,7 +565,7 @@ export const useBearStore = create<MyState>()(
|
||||
}),
|
||||
{
|
||||
name: 'food-storage', // name of item in the storage (must be unique)
|
||||
getStorage: () => sessionStorage, // (optional) by default the 'localStorage' is used
|
||||
storage: createJSONStorage(() => sessionStorage), // (optional) by default the 'localStorage' is used
|
||||
partialize: (state) => ({ bears: state.bears }),
|
||||
}
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user