mrousavy / react-native-mmkv

⚡️ The fastest key/value storage for React Native. ~30x faster than AsyncStorage!
https://mrousavy.com
MIT License
6.13k stars 259 forks source link

Error setting `mode` as multi_process #750

Closed erickriva closed 2 weeks ago

erickriva commented 2 weeks ago

Version: 3.0.2 OS: Android 14 Using new architecture

Error: Value is a number, expected a String

when using

import { MMKV, Mode } from "react-native-mmkv";
const database = new MMKV({ mode: Mode.MULTI_PROCESS });

Setting mode to MULTI_PROCESS (as a string) makes it work, but Mode enum is expected so Typescript complains.

maintenance-hans[bot] commented 2 weeks ago

Guten Tag, Hans here 🍻. It looks like ze issue you are experiencing might be related to how ze Mode enum is being interpreted.

Make sure you are importing ze enum correctly, and try using it as follows:

const database = new MMKV({ mode: Mode.MULTI_PROCESS });

If you are still having problems, could you please provide logs from adb logcat when ze error occurs? Ze logs will help mrousavy understand ze problem better.

Also, if you enjoy using this library and want to support it, consider becoming a sponsor here. This can help mrousavy continue ze great work!

Looking forward to your response!

Note: If you think I made a mistake, please ping @mrousavy to take a look.

mrousavy commented 2 weeks ago

Interesting. I'm guessing this is a codegen bug

mrousavy commented 2 weeks ago

fixed in https://github.com/mrousavy/react-native-mmkv/pull/754 🔥