douglasjunior / react-native-keyboard-manager

⚛ Library to prevent issues of keyboard sliding up and cover inputs on React-Native iOS projects.
https://www.npmjs.com/package/react-native-keyboard-manager
MIT License
971 stars 59 forks source link

null is not an object (evaluating '_reactNativeKeyboardManager.default.... #53

Closed ldco2016 closed 5 years ago

ldco2016 commented 5 years ago

I am running RN 60.4 so my understanding is that it links automatically after installation.

I am running React Native 60.4.

I am running react-native-keyboard-manager@4.0.13-15

Yes, I upgraded from RN 0.53.3 where it used index.ios.js and index.android.js, but with RN 60.4 its now all index.js. So my question is, if I used to have this configuration:

import KeyboardManager from "react-native-keyboard-manager";
// old config code ^^^
import NFIBEngage from "./App";
import { name as appName } from "./app.json";

// old config code
import { Sentry } from "react-native-sentry";

Sentry.config(
  "https://f33c27ee79b04c1bb5117cac6a97d03c@sentry.io/264268"
).install();

KeyboardManager.setToolbarPreviousNextButtonEnable(true);
// old config code ^^^

inside of index.ios.js, where do I place it now that its all index.js for both android and ios? I believe that is why my android emulator is complaining, because its receiving this library and it does not need it.

yes

douglasjunior commented 5 years ago

This issue is related to the link of native modules and the new autolink.

In React Native 0.60.0 autolink has been added, where you no longer need to run react-native link after installing the library.

Try to unlink React Native Keyboard Manager:

$ react-native unlink react-native-keyboard-manager

And let React Native autolink for you.

See this discussion: https://github.com/douglasjunior/react-native-keyboard-manager/pull/51#issuecomment-514874960

ldco2016 commented 5 years ago

Hi @douglasjunior , the problem is not just unlinking it. The problem is that RN 60.4 no longer makes the distinction between index.ios.js and index.android.js, its all now index.jsand so both android and ios has access to that library and android is complaining about it.

I have tested this by simply commenting out react-native-keyboard-manager from my index.js file:

/**
 * @format
 */

import { AppRegistry } from "react-native";
// old config code
// import KeyboardManager from "react-native-keyboard-manager";
// old config code ^^^
import NFIBEngage from "./App";
import { name as appName } from "./app.json";

// old config code
import { Sentry } from "react-native-sentry";

Sentry.config(
  "https://f33c27ee79b04c1bb5117cac6a97d03c@sentry.io/264268"
).install();

// KeyboardManager.setToolbarPreviousNextButtonEnable(true);
// old config code ^^^

AppRegistry.registerComponent("NFIBEngage", () => NFIBEngage);

When I do so the app boots up just fine in android, but my ios side still needs that react-native-keyboard-manager so, where do we place KeyboardManager.setToolbarPreviousNextButtonEnable(true); now that there no longer exists a index.ios.js?

douglasjunior commented 5 years ago

You cant use KeyboardManager with any others platforms than iOS, so you need to do something like this:

import { Platform } from 'react-native';
import KeyboardManager from "react-native-keyboard-manager";

if (Platform.OS === 'ios') {
    KeyboardManager.doSomething();
}
ldco2016 commented 5 years ago

@douglasjunior , that's what I wanted to confirm. Thank you!

SrBrahma commented 2 years ago

@douglasjunior i am having

App.js (647:882) null is not an object (evaluating '_reactNativeKeyboardManager.default.setEnable') (Device)

Evaluating module://App.js.js
Loading module://App.js

on the Expo Go Snack, on physical iOS, iPhone 8.

As it certainly works when installing on a actual project, I tried to use it on the Snack to try a little thing before choosing what lib to use on my project.

douglasjunior commented 2 years ago

I think this library works with Expo 44, but I cant confirm that.

I never particularly used it in a real project with Expo, and in Snack it still doesn't work.

SrBrahma commented 2 years ago

Thanks for the quick answer!

E que bom encontrar brasileiros autores de pacotes RN por aqui!