Could not find component config for native component
Warning: Invariant Violation: View config getter callback for component `xxxxxx` must be a function (received `undefined`).
Warning: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
关于上面这三个问题主要关注以下几点:
1.
create-react-native-library 使用哪种模式创建的本地库,不同的方式会遇到不一样的错误提示
- Turbo module
- Fabric view
- Nitro module
- Legacy Native module
- Legacy Ntive View
- JavaScript Library
2.
package.json
...
"main": "./src/index.tsx" // 不要使用./lib/module/index.js
...
3.
MainProject: 主项目
CustomView:自定义的View项目
MainProject安装CustomView组件后,在主项目的node_modules/CustomView/如果在这个目录下还有node_modules,需要清除否则会报错不能找到自定义组件,这是一个node_modules的嵌套问题,大概意思是如果你有嵌套,那么CustomView会归属到分支模块树上,主模块树就找不到该组件了