react-native - 我正在使用包 react-native-community/blur。但是通过与 UIManager 相关的错误运行应用程序

标签 react-native react-native-ios

我在我的应用程序中添加了包: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
  }
});

最佳答案

执行此指令:

  1. 关闭您的应用
  2. 再次运行命令:react-native run-ios

注意:不要使用 npx 或任何其他命令,只需运行 react-native run-ios

关于react-native - 我正在使用包 react-native-community/blur。但是通过与 UIManager 相关的错误运行应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57524067/

相关文章:

android - 在android上 react native 获取网络请求失败

javascript - 如何使用 React Native GestureDetector 来解释多种不同的手势?

android - 如何设计兼容所有设备的 React Native 屏幕

react-native - Expo (react native) 淡出闪屏

IOS Testflight 即使在更新到新版本后也会加载我的应用程序的旧代码

javascript - React Native - 动画完成后奇怪的闪光

react-native - fetch 的 fileReader 阻止 React Native Prop 更新

react-native - 安装 Expo CLI 的无限循环

javascript - react-native modal 后面的元素不可点击

react-native - Xcode 12 问题 : "Build input file cannot be found "- Building for release on a react native app