Muh*_*hir 75 reactjs react-native
我无法解决这个问题。当应用程序加载时,本机会抛出警告。
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.
Run Code Online (Sandbox Code Playgroud)
any*_*nya 47
这可能是由于最新版本的react-native 造成的。许多库仍然没有发布新版本来处理这些警告(或在某些情况下的错误)。示例包括https://github.com/react-navigation/react-navigation/issues/9882和https://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
Run Code Online (Sandbox Code Playgroud)
Saj*_*eed 27
我只是向主 java 模块添加了两个函数:
// Required for rn built in EventEmitter Calls.
@ReactMethod
public void addListener(String eventName) {
}
@ReactMethod
public void removeListeners(Integer count) {
}
Run Code Online (Sandbox Code Playgroud)
示例:修复将react-native-fs函数添加到android/src/main/java/com/rnfs/RNFSManager.java文件中的警告。
对于 Kotlin,请使用以下代码:
@ReactMethod
fun addListener(type: String?) {
// Keep: Required for RN built in Event Emitter Calls.
}
@ReactMethod
fun removeListeners(type: Int?) {
// Keep: Required for RN built in Event Emitter Calls.
}
Run Code Online (Sandbox Code Playgroud)
小智 6
同样的错误。
改变
const eventEmitter = new NativeEventEmitter(NativeModules.CustomModule);
Run Code Online (Sandbox Code Playgroud)
到
const eventEmitter = new NativeEventEmitter();
Run Code Online (Sandbox Code Playgroud)
作品
这是与 React Native 复活库相关的问题。我通过卸载库并重新安装来解决它。删除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 中打开项目。转到文件->使缓存无效。之后一切正常。
| 归档时间: |
|
| 查看次数: |
102602 次 |
| 最近记录: |