javascript - 不变违规:requireNativeComponent:“BVLinearGradient”
问题描述
我一直在使用,react-native-gradient
并且收到有关该软件包的以下错误。
错误
Invariant Violation: requireNativeComponent: "BVLinearGradient" was not found in the UIManager.
This error is located at:
in BVLinearGradient (at react-native-linear-gradient/index.ios.js:54)
in LinearGradient (at SignupLogin.js:46)
in RCTView (at View.js:34)
in View (at createAnimatedComponent.js:165)
in AnimatedComponent (at createAnimatedComponent.js:215)
in ForwardRef(AnimatedComponentWrapper) (at TouchableOpacity.js:224)
.........
in View (at AppContainer.js:106)
in DevAppContainer (at AppContainer.js:121)
in RCTView (at View.js:34)
in View (at AppContainer.js:132)
in AppContainer (at renderApplication.js:39)
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue
用法
...
import * as Animatable from "react-native-animatable";
import LinearGradient from "react-native-linear-gradient";
import MaterialIcons from "react-native-vector-icons/MaterialIcons";
import { useTheme } from "@react-navigation/native";
const SignupLogin = ({ navigation }) => {
const { colors } = useTheme();
return (
<View style={styles.container}>
.....
<View style={styles.button}>
<TouchableOpacity onPress={() => navigation.navigate("sign-in")}>
<LinearGradient
colors={["#0831d4", "#0131ab"]}
style={styles.signIn}
>
<Text style={styles.textSign}>Get started</Text>
<MaterialIcons name="navigate-next" color="#fff" size={20} />
</LinearGradient>
.....
</View>
);
};
export default SignupLogin;
它是页脚登录和注册菜单之间的简单导航,App.js
其余文件采用标准编码方法。
解决方案
确认您安装react-native-linear-gradient
yarn add react-native-linear-gradient
在ios中确认ios/podfile
有这条线
pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
然后pod install
在ios文件夹中运行
推荐阅读
- python - 如何将世纪值(即 1900 和 2000)添加到 pandas 列中的十年
- python-2.7 - 熊猫新专栏有条件
- c# - 如何在有头的 UWP IoT Core 应用程序中调用 IHost 的 Run()
- android - 我已经创建了通知通道,但在 Android 8.1.0 上崩溃的可能性仍然很低 startForeground 的错误通知
- android - 当我阅读条形码时,Listview 项目数据重复
- google-cloud-platform - 在获得谷歌云计算引擎的管理员访问权限后,如何创建项目和 VM 实例?
- javascript - 我想制作一个函数,在 php 中按函数打印插入查询。问题 :
- mysql - 1 小时内的 MySQL 查询选择
- stackdriver - Stackdriver 保留政策为 30 天。Stackdriver 信息中心如何设法显示过去 6 周的数据?
- android - 我可以使用整个原生项目与原生 UI 进行原生反应吗?