使用非空参数调用了新的 NativeEventEmitter(),而没有必需的 \`addListener\` 方法

新手上路,请多包涵

我无法解决问题。当应用程序加载反应原生抛出警告。

 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.
WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.

原文由 Muhammad Tahir 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 2.9k
2 个回答

这是与 react native reanimated library 相关的问题。我通过卸载库并重新安装它来解决它。删除 https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation 提供的 react-native-reanimated 库的所有安装步骤。

只需使用命令 npm install react-native-reanimated@2.3.0-beta.1 安装库

如果问题仍然存在,请在 android studio 中打开项目。转到文件-> 使缓存无效。之后一切正常。

原文由 Muhammad Tahir 发布,翻译遵循 CC BY-SA 4.0 许可协议

这可能是由于最新版本的 react-native。许多库仍然没有发布新版本来处理这些警告(或某些情况下的错误)。示例包括 https://github.com/react-navigation/react-navigation/issues/9882https://github.com/APSL/react-native-keyboard-aware-scroll-view/pull/501 。如果它困扰您,您可以暂时隐藏警告( 来源):

 import { LogBox } from 'react-native';
LogBox.ignoreLogs(['new NativeEventEmitter']); // Ignore log notification by message
LogBox.ignoreAllLogs(); //Ignore all log notifications

原文由 anya 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题