ITADN

useMMKV hooks return stale value when used with React <Activity/>

#1006OpenKijongHan 创建于 2026-02-22
K
KijongHancommented
minimum repro setup here with source code changes in the example folder under `App.tsx`: https://github.com/KijongHan/react-native-mmkv/tree/reproduce/useMMKV-hooks-returning-stale-values Two test components are set up so that TestB is under an `Activity` component whose visibility mode toggles on/off depending on a react state. TestB subscribes using useMMKV hook. TestA is under an Activity that is always visible and also subscribes to the same hook and key subscribed for TestB when you update the key value from the parent while TestB is not visible, TestA listens to the updated changes as expected. When you toggle visibility for TestB, it reads and listens to a stale value for the mmkv key
1 条评论