Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: _reactNativeMmkv.MMKV.set is not a function #1

Closed
alexkendall opened this issue Feb 25, 2021 · 11 comments
Closed

TypeError: _reactNativeMmkv.MMKV.set is not a function #1

alexkendall opened this issue Feb 25, 2021 · 11 comments

Comments

@alexkendall
Copy link

Steps
yarn install
cd ios && pod install

import {MMKV} from 'react-native-mmkv
...
MMKV.set(email, LAST_TYPED_EMAIL)

After entering that code I get the error TypeError: _reactNativeMmkv.MMKV.set is not a function. Furthermore, after logging the MKV object, I have attached the following screen. It seems there is an issue with the native code and JS not being linked as all the methods are undefined.

Screen Shot 2021-02-24 at 9 16 57 PM

@KingAmo
Copy link

KingAmo commented Feb 25, 2021

same here
image

react-native info:

System:
    OS: macOS 11.2.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 377.21 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.19.0 - /usr/local/bin/node
    Yarn: 1.22.5 - ~/.yarn/bin/yarn
    npm: 7.5.6 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 21, 23, 25, 26, 27, 28, 29
      Build Tools: 23.0.1, 26.0.1, 26.0.2, 27.0.3, 28.0.3, 29.0.2
      System Images: android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7042882
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_212 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1
    react-native: ^0.64.0-rc.2 => 0.64.0-rc.2
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

@KingAmo
Copy link

KingAmo commented Feb 25, 2021

enable hermes && do not use chrome debugger (use flipper) fixed the error

@mrousavy
Copy link
Owner

Yes, so you cannot use the Chrome debugger when using JSI. This is due to the fact that when you are debugging with Chrome, your JavaScript actually does not execute on your device and therefore does not have direct access to JSI. (The bridge still works but that's another story).

So you have to use Flipper debugger, or write such good code that you have to never debug again 🤗

@douugdev
Copy link

I'm using hermes, not using chrome debugger but it still says the functions are undefined when I console.log the MMKV alias

image

@mrousavy
Copy link
Owner

@douugbr which MMKV version are you on?

@douugdev
Copy link

The issue was happening on the latest 1.0.11 version, I just tried downgrading to 1.0.10 and it fixed my problem, but I'd be glad to upgrade again to help you in troubleshooting.

@mrousavy
Copy link
Owner

I'm currently investigating this and will rewrite the JSI installer to be a turbo module. That should fix it. So stay on the version that's currently working for you and watch the "Releases" section here ;)

@douugdev
Copy link

Unfortunately it fixed for a short time and just after I reloaded it, the same issue began, this is extremely weird, I tried installing even the 1.0.2 and the same issue was arising, the only explanation is something with my project setup probably

image

@mrousavy
Copy link
Owner

mrousavy commented Apr 8, 2021

@douugbr just to confirm - does it work for you now with the latest version + the (temporary) additional installation steps for Android?

@douugdev
Copy link

douugdev commented Apr 8, 2021

@mrousavy unfortunately, due to the issues I was experiencing that day, I chose to try ammarahm-ed's version of a MMKV RN implementation, but I will install yours again in a side project to test once I have the time to, and if it works I'll let you know.

@mrousavy
Copy link
Owner

mrousavy commented Apr 8, 2021

@douugbr oh yeah he also rewrote it in JSI shortly after I did 😅
all good, use whatever works for you.

mrousavy pushed a commit that referenced this issue Apr 7, 2023
* feat: Support `id` on web

Local storage does not have a concept of separate stores in user code,
this change emulates that behaviour by prefixing the keys in local
storage with `id`.

This retains backwards compatibility with existing web MMKV stores by
treating the the default `mmkv.default` id is as prefixless.

Fixes #520

* feat: Adds a check to key and id values to reject our wildcard character on web (a backslash) (#1)

* feat: Adds a check to key and id values to reject our wildcard character on web (a backslash)

---------

Co-authored-by: Jonathan Jacobs <jonathan@yoco.co.za>
Co-authored-by: CannibalKush <45557293+CannibalKush@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants