ShaMan123 / react-native-math-view

Math view for react native! No WebView!
https://github.com/ShaMan123/react-native-math-view
MIT License
79 stars 25 forks source link

null is not an object (UIManager$getViewMan.Constants) -Android #19

Closed nolife08021 closed 4 years ago

nolife08021 commented 4 years ago

null is not an object (evaluating '_UIManager$getViewMan.Constant)

from line:13-> react-native-math-view/src/android/MathView.tsx

Platform: Android "react-native-math-view": "^3.4.3",

 <MathView
       style={{ex: 50, em:50}}
       color='white'
       math={'x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}'}
    />
ShaMan123 commented 4 years ago

what version of react-native are you on?

nolife08021 commented 4 years ago

what version of react-native are you on?

react-native: 0.59.8

ShaMan123 commented 4 years ago

that's it I believe. You can upgrade but it is really unnecessary. Try the following:

-export const { Constants } = UIManager.getViewManagerConfig(nativeViewName);
+export const { Constants } = UIManager[nativeViewName];

or even

-export const { Constants } = UIManager.getViewManagerConfig(nativeViewName);
+export const { Constants } = {};
nolife08021 commented 4 years ago

that's it I believe. You can upgrade but it is really unnecessary. Try the following:

-export const { Constants } = UIManager.getViewManagerConfig(nativeViewName);
+export const { Constants } = UIManager[nativeViewName];

or even

-export const { Constants } = UIManager.getViewManagerConfig(nativeViewName);
+export const { Constants } = {};

Okay. I will try it.

ShaMan123 commented 4 years ago

ios has no constants exported. for now.

nolife08021 commented 4 years ago

ios has no constants exported

my bad, that was a stupid question.

ShaMan123 commented 4 years ago

try this, it's better:

export const { Constants } = UIManager.getViewManagerConfig ? UIManager.getViewManagerConfig(nativeViewName) : UIManager[nativeViewName];
ShaMan123 commented 4 years ago

reinstall to version 3.4.5

ShaMan123 commented 4 years ago

ios has no constants exported

my bad, that was a stupid question.

Not at all. In future releaseד it will have

ShaMan123 commented 4 years ago

please reply that all is working, including #18

nolife08021 commented 4 years ago

After I reinstall to version 3.4.5

The error becomes -> null is not an object (evaluating '_ref.Constant')

ShaMan123 commented 4 years ago

I am a bit puzzled. but it is not breaking so. reinstall 3.4.7.

nolife08021 commented 4 years ago

I am a bit puzzled. but it is not breaking so. reinstall 3.4.7.

The error still remaining after reinstall to 3.4.7

null is not an object (evaluating '_ref.Constants)

ShaMan123 commented 4 years ago

run this, I want to check if it's null.

 console.log(UIManager.getViewManagerConfig)
ShaMan123 commented 4 years ago

changing to this should work

export const { Constants } = UIManager.getViewManagerConfig(nativeViewName) || {};

make sure it does and I'll bump the version

nolife08021 commented 4 years ago

After Changing it, I received this Invariant Violation: requireNativeComponent: "RNMathView" was not found in the UIManager.

Is it because I using the Expo?

nolife08021 commented 4 years ago

line 13:

export const { Constants } = UIManager.getViewManagerConfig(nativeViewName)

Not able to comment it, because of line 121: MathViewWrapper.Constants = ControlledMathView.Constants = Constants;

But after I replace it with export const { Constants } = UIManager.getViewManagerConfig(nativeViewName) || {};

It will show another error Invariant Violation: requireNativeComponent: "RNMathView" was not found in the UIManager.

**I'm not sure that it solved the Constants issue or not.

ShaMan123 commented 4 years ago

RN 0.59 doesn't do automatic linking. You need to link the package.

nolife08021 commented 4 years ago

react-native link react-native-math-view

Is there any way that I can perform the linking in expo without using ejecting to ExpoKit?

ShaMan123 commented 4 years ago

Native modules aren't supported in expo. You can render the fallback component which is based on react-native-svg. This is likely to affect performance.

import MathViewFallback from 'react-native-math-view/src/fallback';
Youssouf-Ouedraogo commented 4 years ago

@noli

react-native link react-native-math-view

Is there any way that I can perform the linking in expo without using ejecting to ExpoKit?

Did you figure out a way to get it to work in an expo project without ejecting your project? If so, I would greatly appreciate your help. I am getting the same issue

anback commented 3 years ago

If you are like me and ended up with 400 ts errors when importing this module in typescript then here is the solution:

create a types/index.d.ts:

declare module 'react-native-math-view/src/fallback'

declare module 'react-native-math-view/src/android' {
  export type MathViewProps = any
}

and in tsconfig.json add a path in compilerOptions:

    "paths": {
      "react-native-math-view/src/fallback": ["types"],
      "react-native-math-view/src/android": ["types"]
    }
ShaMan123 commented 3 years ago

If you are like me and ended up with 400 ts errors when importing this module in typescript then here is the solution:

create a types/index.d.ts:

declare module 'react-native-math-view/src/fallback'

declare module 'react-native-math-view/src/android' {
  export type MathViewProps = any
}

and in tsconfig.json add a path in compilerOptions:

    "paths": {
      "react-native-math-view/src/fallback": ["types"],
      "react-native-math-view/src/android": ["types"]
    }

Does this happen on Expo?

ghost commented 2 years ago

It's not because of expo, I'm getting it now too

manuelg04 commented 6 months ago

ERROR Invariant Violation: requireNativeComponent: "RNMathView" was not found in the UIManager.

any solutions?