Created
November 29, 2022 23:27
-
-
Save claudesortwell/ed76ecb238dc9e2236c8da92f18de10e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsyncStorage from '@react-native-async-storage/async-storage'; | |
import create from 'zustand'; | |
import { persist } from 'zustand/middleware'; | |
export const useSomthingStore = create<TSomthingStore>( | |
persist( | |
(set, get) => ({ | |
isTrue: false, | |
_hasHydrated: false, | |
setHasHydrated: state => { | |
set({ | |
_hasHydrated: state, | |
}); | |
}, | |
}), | |
{ | |
name: 'somthing-storage', | |
getStorage: () => AsyncStorage, | |
onRehydrateStorage: () => state => { | |
state?.setHasHydrated(true); | |
}, | |
}, | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment