MMKV is not persisting data after app is reopened.
Hello, I am experiencing a weird issue where my app is resetting the entire storage after it is closed and re-opened.
This is the storage configuration:
```js
export const secureStorage = createMMKV({
id: 'secure-storage',
});
```
While using the app, i am able to set and read back multiple variables. I have also tried multi-process and the app seems to work fine.
Only when i close the app and re-open it (metro and expo sitll running in the terminal), all the variables are cleared. I have added logging around and this is happening literally every single time.
I have only recently started transitioning the app into EXPO 55, I am not sure if this could be related to that, but this makes the app unusable. Previously the app has been running on react-native core, without EXPO at all.
Here is one example of the code for setting the variable:
```ts
export const setMMKVSecureStorageItem = ({
key,
value,
}: MMKVSecureStorageParams['set']) => {
try {
secureStorage.set(key, value);
return [true, null];
} catch (e) {
return [false, e];
}
};
```
it returns an array where the first parameter is a boolean to identify if the variable was sucesfully saved or not.
key in this case can be any of ACCESS_TOKEN or SESSION_ID, which i have created as types locally:
```ts
type MMKVSecureStorageTypes = 'ACCESS_TOKEN' | 'SESSION_ID';
```
```ts
// An example of what it would look like to call the set function:
setMMKVSecureStorageItem({
value: data.token,
key: 'ACCESS_TOKEN',
});
```
I have run through the installation and I am using the following versions:
expo: 55.0.4
react-native: 0.83.2
react-native-mmkv: 4.2.0
react-native-nitro-modules: 0.35.0
9 条评论