Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Require Cycle warnings on terminal

I'm continuously getting Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle. warning on my terminal and it has make debugging my program so difficult.

I have used

YellowBox.ignoreWarnings([
  'Require cycle:', 
])

and also

console.disableYellowBox = true;

But neither worked. YellowBox.ignoreWarnings worked only for the warnings displayed on the mobile but not for the warnings on the terminal of my IDE. How can i prevent getting these warnings on the terminal.

like image 915
CraZyDroiD Avatar asked Mar 28 '19 07:03

CraZyDroiD


2 Answers

I commented out the below lines and they stopped appearing in both terminal and the device.

node_modules/metro/src/lib/polyfills/require.js (Line 114)

  console.warn(
    "Require cycle: ".concat(cycle.join(" -> "), "\n\n") +
      "Require cycles are allowed, but can result in uninitialized values. " +
      "Consider refactoring to remove the need for a cycle."
  );

After commenting out that warning, restarting the project fixed my issues. PS. I'm using expo.

like image 94
Thu San Avatar answered Oct 07 '22 21:10

Thu San


My solution for this issue, hope it helps others:

import { AppRegistry, LogBox } from 'react-native';
import App from './App';
import { name as appName } from './app.json';

LogBox.ignoreLogs(['Require cycle:']);

AppRegistry.registerComponent(appName, () => App);
like image 2
Phan Kiet Avatar answered Oct 07 '22 22:10

Phan Kiet