react-native-builder-bob icon indicating copy to clipboard operation
react-native-builder-bob copied to clipboard

nvariant Violation: View config getter callback for component `ComponentName` must be a function (received `undefined`).

Open sergeymild opened this issue 4 years ago • 9 comments

Environment

"dependencies": { "react": "17.0.1", "react-native": "0.64.2", "react-native-bottom": "file:../react-native-bottom" }, "devDependencies": { "@babel/core": "^7.14.3", "@babel/runtime": "^7.14.0", "@react-native-community/eslint-config": "^2.0.0", "babel-jest": "^27.0.2", "eslint": "^7.28.0", "jest": "^27.0.4", "metro-react-native-babel-preset": "^0.66.0", "react-test-renderer": "17.0.1" },

Description

I create native library with command line tools create-react-native-library and choose Native view (to use as a component) everything is ok, but after i connect created library to my project, import component and connect in jsx. i seed this strange error Invariant Violation: View config getter callback for component ComponentName must be a function (received undefined).

Reproducible Demo

To reproduce, just create a library with option Native view (to use as a component) after connect it to React native project (not to example project witch includes in library) and you will see that error

sergeymild avatar Jun 06 '21 06:06 sergeymild

I am experiencing the exact same issue.

rosenbergm avatar Jun 12 '21 15:06 rosenbergm

I am also facing the same issue. I am unabe to import the view from Native Library. I tried to bump the react native versions but it did not help as well.

murtazabeans avatar Jun 15 '21 00:06 murtazabeans

after connect it to React native project

What do you mean by connect here? Are you using npm or yarn (they both have different behavior)? Did you try installing it as a regular package (e.g. publish to a registry, verdaccio for local testing) instead of using file: protocol? It's helpful to actually provide a repro because there are always things which aren't clear.

If it doesn't work with file: protocol only, it's related to CLI's autolinking and you should open an issue in react Native CLI repo.

satya164 avatar Jun 15 '21 01:06 satya164

@satya164 , I created a Native view and packaged it using npm run prepare and npm pack. Now, it creates a local package and I am using this package in a fresh new example application. I used normal npx react-native init AppName --template react-native-template-typescript. When I try to import this view in my app.js file it complains that the view is not found. I am able to call the API's in native modules but not able to import the view.

murtazabeans avatar Jun 15 '21 01:06 murtazabeans

Try running yarn command on the root project. It should make this work. It worked for me and now I can get the component view from native side

murtazabeans avatar Jun 15 '21 21:06 murtazabeans

@murtazabeans Could you explain more about Try running yarn command on the root project. I have the same problem. Thanks in advance

JonghunYu avatar Jul 01 '21 11:07 JonghunYu

Try running yarn command on the root project. It should make this work. It worked for me and now I can get the component view from native side

I ran yarn install, yarn prepare, yarn pod on the lib, and yarn install, yarn ios on the project but I still have the same problem...

snowmen10 avatar Aug 20 '21 02:08 snowmen10

any update? Just realise this is caused by react native 0.63 +

jp928 avatar Nov 26 '21 03:11 jp928

@sergeymild I found the solution is here:

https://github.com/facebook/react-native/issues/31512

jp928 avatar Nov 26 '21 05:11 jp928