现在,我正在使用本机生成一个应用程序。 几天前,我需要在我的应用中使用Modal,因此我已经安装了“ react-native-modalbox”。(https://github.com/maxs15/react-native-modalbox)
但是在那之后,我得到了如下图所示的警告。
我没有这个意思和解决这个问题的方法。
答案 0 :(得分:0)
我认为此警告只是不影响代码的警告。
这仅仅是地铁警告。
但是,如果您想摆脱这种情况,
import { YellowBox } from "react-native";
YellowBox.ignoreWarnings(["Require cycle:", "Remote debugger"]);
希望您能参考this.
OR
我引用了此link
在项目中添加一个scripts
文件夹
使用以下内容创建一个stfu.js
文件
const fs = require('fs');
const codeToObscure = /console.warn\([\s\S].*"Require cycle: "/;
const problemFilePath = './node_modules/metro/src/lib/polyfills/require.js';
const problemFileContent = fs.readFileSync(problemFilePath,'utf8');
fs.writeFileSync(problemFilePath,problemFileContent.replace(codeToObscure,'const noConsoleWarn = (""'),'utf8');
将以下行添加到package.json
中的scripts
中:"postinstall": "node ./scripts/stfu.js"
,
完成后,只需rm -rf node_modules && yarn
重新安装所有内容,并确保这些该死的警告现在都消失了。
我希望这些方法对您有用。