我在我的应用程序中添加了包:react-native-community/blur
。并尝试运行它。但它在运行时会抛出错误,如下所述。任何修复它或任何解决方案?
Error:"Invariant Violation: requireNativeComponent: "BlurView" was not found in the UIManager".
我已经尝试重新安装 pod,也检查了我的 yarn 版本。
import React, { Component } from "react";
import { View, Image, Text, findNodeHandle, StyleSheet } from "react-native";
import { BlurView } from "@react-native-community/blur";
export default class Menu extends Component {
constructor(props) {
super(props);
this.state = { viewRef: null };
}
imageLoaded() {
this.setState({ viewRef: findNodeHandle(this.backgroundImage) });
}
render() {
return (
<View style={styles.container}>
<Text>Hi, I am some unblurred text</Text>
<BlurView
style={styles.absolute}
viewRef={this.state.viewRef}
blurType="light"
blurAmount={10}
/>
<Image
ref={img => {
this.backgroundImage = img;
}}
//source={{ uri }}
source={{uri: 'https://facebook.github.io/react-native/img/tiny_logo.png'}}
style={styles.absolute}
onLoadEnd={this.imageLoaded.bind(this)}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
justifyContent: "center",
alignItems: "center"
},
absolute: {
position: "absolute",
top: 0,
left: 0,
bottom: 0,
right: 0
}
});
最佳答案
执行此指令:
- 关闭您的应用
- 再次运行命令:react-native run-ios
注意:不要使用 npx 或任何其他命令,只需运行 react-native run-ios
关于react-native - 我正在使用包 react-native-community/blur。但是通过与 UIManager 相关的错误运行应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57524067/