Update Recipes persist example to match example in Persisting Store Data integration (#1813)

Replace the deprecated `getStorage` option with the new `storage` option with `createJSONStorage`.
This commit is contained in:
Will McBride 2023-05-17 16:53:10 -06:00 committed by GitHub
parent 286e4436c7
commit d61b70fd8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -320,7 +320,7 @@ You can persist your store's data using any kind of storage.
```jsx
import { create } from 'zustand'
import { persist } from 'zustand/middleware'
import { persist, createJSONStorage } from 'zustand/middleware'
export const useStore = create(
persist(
@ -329,8 +329,8 @@ export const useStore = create(
addAFish: () => set({ fishes: get().fishes + 1 }),
}),
{
name: 'food-storage', // unique name
getStorage: () => sessionStorage, // (optional) by default the 'localStorage' is used
name: 'food-storage', // name of the item in the storage (must be unique)
storage: createJSONStorage(() => sessionStorage), // (optional) by default, 'localStorage' is used
}
)
)