React-Native自有组件开发时的麻烦

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会归属到分支模块树上,主模块树就找不到该组件了

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值