我使用的是一个npm包,它需要如下的events模块
var EE = require('events').EventEmitter;
这在React Native中失败,因为找不到事件模块。如何解决这个问题?我知道我可以在react-native中做var EE = require('EventEmitter');,但是npm包处理这个问题的正确方式是什么(例如,兼容node和react-native)?
我是react native的新手,当我运行我的react native项目时,我收到了这个警告或错误。 ReactNativeJS ▶︎ 'EventEmitter.removeListener(\'change\', ...): Method has
been deprecated. Please instead use `remove()` on the subscription returned by
`EventEmitter.addListener`.
在使用模块react-native-push-notification时,出现了以下错误:
FAIL __tests__/index.android.js
● Test suite failed to run
Invariant Violation: Native module cannot be null.
at invariant (node_modules/fbjs/lib/invariant.js:44:15)
at new NativeEventEmitter (node_modules/react-native/Libraries/Eve
处理从0.52升级到RN 0.59.10时的babel / jest问题。任何帮助,具体的或定向的,都是非常感谢的。
我们的测试通过了RN 0.52。我希望这些是配置问题,而不是结构问题。
问题:调用/构造函数错误。有几个测试在deps中的超级调用(如RN的EventEmitter)或新的新调用(结果对象未定义)上失败。
示例:
test suite failed to run
TypeError: Cannot read property 'call' of undefined
at new RCTDeviceEventEmitter (node_modu
我已经安装了jest-expo,但是当我运行我的测试时,我得到一个错误: react-native/jest-preset contained different transformIgnorePatterns than expected
Invariant Violation: Native module cannot be null.
at invariant (node_modules/invariant/invariant.js:40:15)
at new NativeEventEmitter (node_modules/react-native/Libr
我安装了@react-native-firebase的v6,它按预期工作,但当我尝试运行单元测试时,我得到了以下错误:
Jest encountered an unexpected token
Details:
/node_modules/@react-native-firebase/database/lib/index.js:18
import { isBoolean, isNumber, isString } from '@react-native-firebase/app/lib/common';
^
SyntaxError: Unexpected t
我尝试在react中运行默认测试--本机使用jest,我发现了以下问题:
Test suite failed to run
Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.
at invariant (node_modules/invariant/invariant.js:40:15)
at new NativeEventEmitter (node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js
我有一个Reactinative中的项目,该项目利用来存储由子屏幕编辑的数据。由于我们需要全局侦听每个键的更改,所以我做了以下使用EventEmitter的Asyncstorage挂钩:
import AsyncStorage from "@react-native-async-storage/async-storage";
import EventEmitter from "eventemitter3";
import { useEffect, useState } from "react";
const eventEmitter = new
我在做一个博览应用程序。我想使用环境变量,所以我安装了dotenv软件包。当我在我的.config中添加要求(‘dotenv’) App.js ()时,我得到了这个错误。
undefined Unable to resolve module fs from C:\Users\RohitMaurya\Music\kaam_karo\frontend\GoalrApp\node_modules\dotenv\lib\main.js: fs could not be found within the project.
If you are sure the module exists, try t
我正在使用ES2015,Jest,React做一个练习,我得到了这样的错误:
TypeError: Property description must be an object: undefined
at defineProperties (native)
at Object.eval (<PROJECT>/node_modules/event-emitter/index.js:127:8)
在深入研究之后,我认为它与导入nodeModule EventEmitter或通过它扩展类有关。
这是脚本文件的代码:
import EventEmitter from 'event-
我有一个使用Expo.WebBrowser的基本示例,它给出了错误:
import { WebBrowser } from 'expo'
'expo' does not contain an export named 'WebBrowser'
依赖关系:
"buffer": "^5.1.0", "color-hash": "^1.0.3", "debug": "^3.1.0", "eventemitter2":
我想在我的React本地应用程序上使用google功能来实现登录。我用的是expo-cli,我用的是世博authSession。
LoginScreen.js
import * as React from "react";
import * as WebBrowser from "expo-web-browser";
import * as Google from "expo-auth-session/providers/google";
import { Button, View, Text, TouchableOpacity } from &
我正在尝试使用Axios运行一个API调用,在Android上使用Expo来响应本地版,但我遇到了一个网络错误。我尝试了一些解决办法,但似乎没有什么效果。这是控制台中显示的错误:
Network Error
at node_modules\\axios\\lib\\core\\AxiosError.js:3:0in \<global\>
at node_modules\\axios\\lib\\adapters\\xhr.js:138:8 in handleAbort
at node_modules\\event-target-shim\\dist\\event-target-sh
我试图使用expo start命令运行我的react原生项目,一切正常,但我得到了这个错误-
error Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class.
Metro Bundler process exited with code 1
Error: Metro
我在这里学习了ES6的例子。
我的代码:
import {EventEmitter} from 'react-native';
class A extends EventEmitter {
constructor() {
super();
}
}
export const a = new A();
当我在自己的(RN0.68)中运行这个程序时,我会收到以下消息,并在应用程序中显示一个红色错误屏幕:
ERROR TypeError: Super expression must either be null or a function