Search code examples
react-nativeintellij-ideaexpo

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.


Solution

  • 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.