问题描述
概述:
我使用 TypeScript 构建了一个 NPM 库,距离上次更新它已经快 9 个月了(我没有时间)。但是,它使用以下库:
- react-native-modal
- @react-native-picker/picker(曾经是 @react-native-community/picker,但该库现在已弃用,取而代之的是新库)
- @react-native-community/datetimepicker
我的图书馆(react-native-ultimate-modal-picker)package.json
:
我已将上面列出的所有 3 个库都设置为 peerDependencies
,但我不确定我是否遗漏了诸如 podfiles
之类的其他内容。
"peerDependencies": {
"@react-native-community/datetimepicker": ">=3.0.0","@react-native-picker/picker": ">=1.8.3","react": "*","react-native": "*","react-native-modal": ">=11.0.0"
},
什么有效:
代码在 iOS 模拟器中运行时有效,但将我的库 react-native-ultimate-modal-picker 添加到项目时,它给出了错误。
错误:
Error: Invariant Violation: requireNativeComponent: "RNCPicker" was not found in the UIManager.
将 NPM 库导入项目:
import { DropdownList } from 'react-native-ultimate-modal-picker';
const testItems: Array<PickerValue> = [
{ label: '1',value: '1' },];
<DropdownList
title="Test"
items={testItems}
onChange={(value: string) => console.log(value)}
/>
Github Repo(我的图书馆目前无法使用)
https://github.com/jefelewis/react-native-ultimate-modal-picker
问题的可能原因:
-
podfiles
? - 缓存?
- NPM 库的构建/导出不当?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)