如何解决未处理的承诺拒绝:错误:无法激活保持清醒React Native

Nts*_*ane 7 react-native

你好,我是 React Native 的新手,所以我正忙于了解它的要点,所以在添加这段代码后,我开始收到以下错误。

[Unhandled promise rejection: Error: Unable to activate keep awake]
- node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:103:50 in   promiseMethodWrapper
- node_modules/@unimodules/react-native-adapter/build /NativeModulesProxy.native.js:15:23 in moduleName.methodInfo.name
- node_modules/expo-keep-awake/build/index.js:10:58 in activateKeepAwake
- node_modules/expo/build/launch/registerRootComponent.expo.js:6:4 in <global>
- node_modules/metro/src/lib/polyfills/require.js:321:11 in loadModuleImplementation
- node_modules/expo/AppEntry.js:1:0 in <global>
- node_modules/metro/src/lib/polyfills/require.js:321:11 in loadModuleImplementation
- node_modules/metro/src/lib/polyfills/require.js:201:44 in guardedLoadModule
* http://192.168.1.96:19001/node_modules/expo/AppEntry.bundle?platform=android& dev=true&minify=false&hot=false:154700:3 in global code
Run Code Online (Sandbox Code Playgroud)

下面是我添加的可能导致该错误的代码

import { FloatingAction } from "react-native-floating-action";
const FloatingHomeButton = () => {
  const actions = [
    {
      text: "Accessibility",
      icon: require("../images/tweet.png"),
      name: "bt_accessibility",
      position: 2,
    },
  ];
  return (
    <View style={styles.button}>
      <FloatingAction
        actions={actions}
        onPressItem={() => {
          console.log(`selected button`);
        }}
      />
    </View>
  );
};
Run Code Online (Sandbox Code Playgroud)

我能否获得有关如何解决此问题的帮助,如果可能的话,能否告诉我可能导致此错误的原因

小智 2

我认为您错过了View从“react-native”导入组件。 尝试这个:

import { View } from 'react-native';
Run Code Online (Sandbox Code Playgroud)

我希望这对您的问题有所帮助。