我使用的是包react-native-communityblur。但是在运行应用程序的过程中出现了一个与UIManager相关的错误。

问题描述 投票:0回答:1

我已经在我的应用程序中添加了这个包。react-native-community/blur 在我的应用程序中, 并尝试运行它。但它在运行时抛出一个错误,如下所述。任何修复它或任何解决方案?

Error:"Invariant Violation: requireNativeComponent: "BlurView" was not found in the UIManager".

我已经尝试重新安装pods,也检查了我的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 react-native-android react-native-ios
1个回答
0
投票

首先,关闭你的应用程序。

如果你是在Android上,在Android Studio中打开你的项目的android目录,然后同步你的项目与Gradle(它可能会自动发生,但如果它不这样做,然后自己)。

如果是ios,运行 npx pod-install 或将文件cd到ios文件夹中并运行 pod install.

重新运行你的应用程序。npx react-native run-android.如果是ios,运行 npx react-native run-ios

© www.soinside.com 2019 - 2024. All rights reserved.