react-native-mmkv icon indicating copy to clipboard operation
react-native-mmkv copied to clipboard

Bug on RN 0.74

Open Zarinia opened this issue 9 months ago • 10 comments

When run in RN 0.73.7 all things are ok but RN 74 failed on Android with this message: Error: Failed to create a new MMKV instance: React Native is not running on-device. MMKV can only be used when synchronous method invocations (JSI) are possible. If you are using a remote debugger (e.g. Chrome), switch to an on-device debugger (e.g. Flipper) instead.

Zarinia avatar Apr 28 '24 12:04 Zarinia

The new version for RN 0.74 is still work in progress. You can use beta channel to test it out but I am not sure if it's production ready.

matinzd avatar Apr 28 '24 20:04 matinzd

Thanks for your feedback, I tested version 3.0.0-beta.1 but my problem still exists.

Zarinia avatar Apr 29 '24 05:04 Zarinia

The mentioned issue above is not only for Android, but it is also for iOS, I encountered the issue after upgrading my RN app to 0.74 too. I thought it might be due to third-party integration, but it throws the error on the metro for a fresh app as well (the build is OK).

It seems that the module cannot be installed or something similar when creating new instance, which throws the error:

if (global.nativeCallSyncHook == null || MMKVModule.install == null) {
  throw new Error(
    'Failed to create a new MMKV instance: React Native is not running on-device. MMKV can only be used when synchronous method invocations (JSI) are possible. If you are using a remote debugger (e.g. Chrome), switch to an on-device debugger (e.g. Flipper) instead.'
  );
}

Mhp23 avatar Apr 29 '24 09:04 Mhp23

RN 0.74 is WIP here: https://github.com/mrousavy/react-native-mmkv/pull/656

mrousavy avatar Apr 29 '24 09:04 mrousavy

If you need this faster, consider sponsoring me to accelerate the development here. Currently I am working on VisionCamera instead of RN MMKV.

mrousavy avatar Apr 29 '24 09:04 mrousavy

Try using react-native-mmkv@beta (beta.5), this one works on react-native 0.74.0 and is built with a pure C++ TurboModule! (requires the new arch to be enabled)

RN MMKV V3 should now also be much faster.

mrousavy avatar Apr 30 '24 16:04 mrousavy

Try using react-native-mmkv@beta (beta.5), this one works on react-native 0.74.0

I just tried and so far it seems to work!

miafoo avatar Apr 30 '24 18:04 miafoo

The beta 5 now It's working on both platforms. Thank you @mrousavy

Mhp23 avatar Apr 30 '24 18:04 Mhp23

Yeah, beta 5 is working fine thanks

Zarinia avatar Apr 30 '24 18:04 Zarinia

Awesome, if you appreciate my dedication please consider sponsoring. Lots of time went into the C++ rewrite

mrousavy avatar Apr 30 '24 19:04 mrousavy

Can't we use react native dev tool instead of flipper?

divyansh0908nl avatar Aug 11 '24 19:08 divyansh0908nl

I just released react-native-mmkv 3.0.0, so V3 is now stable and works on the new architecture as a pure C++ TurboModule - blazingly fast! 🔥

mrousavy avatar Aug 27 '24 10:08 mrousavy

Can we continue using 2.12 with React native 0.74? I don't want to enable the new architecture yet as it leads to some unexpected bugs

alextbogdanov avatar Sep 20 '24 17:09 alextbogdanov