react-native-mmkv
react-native-mmkv copied to clipboard
useMMKVObject hook causing issue in app.
I am getting this error when using useMMKVObject
hook within our own custom hook wrapper. While this issue is related to redux it is being initiated by the set
call in the hook. In order to work around this I switched the code to use without the hook but also believe I lose the listener effect that a hook. Any help or insight would be appreciated, and thank you for the library.
const useSubscription = (shouldHandleRedirect = false) => {
const subscription = useSelector((state) => state.iapSubscription)
const [localSubscription] = useMMKVObject('subscription')
// .. replacing with line below fixes the issue
// const localSubscription = JSON.parse(storage.getString('subscription'))
const [isConnected, setIsConnected] = useState(true)
const userProgram = useSelector(
({ firestore }) => firestore.data?.userProgram
)
const [hasSubscription, setHasSubscription] = useState(true)
const userRole = useSelector(
({ firebase: { profile } }) => profile?.role
)
const dispatch = useDispatch()
const navigation = useNavigation()
useEffect(() => {
// Work with data...
}, [subscription, localSubscription, isConnected, userRole, userProgram])
...
}
