How to Disable Yellow Warning Box in React Native

React Native Yellow Warning Box

This is How to Disable Yellow Warning Box in React Native. This Yellow warning box can be helpful if you want to know any warning but can be annoying at the same time if you know the issue and want to ignore that.

In the second case where you want to ignore the error and it is also blocking necessary pieces of the application, you can disable it.

To Disable Warning Box in React Native

To disable warning in React Native you just need to add the following line in your App.js file

console.disableYellowBox = true;

Update:

For the latest version of React Native console will be deprecated completely as React Native 0.63 version brought LogBox. For disabling the LogBox Warning you can use

import { LogBox } from 'react-native';

// Ignore log notification by message
LogBox.ignoreLogs(['Warning: ...']);

//Ignore all log notifications
LogBox.ignoreAllLogs();

Code with Yellow Warning

So here is a demo code which has Yellow Warning (Suppose)

//Disable Yellow Warning Box
//https://aboutreact.com/disable-react-native-yellow-box-warnings/

//import React in our code
import React from 'react';

//import all the components we are going to use
import { View } from "react-native";

const App = () => {
  return (
    <View> {/*Your Code will be here*/} </View>
  );
};

export default App;

Screenshot with Yellow Warning

Code after Disabling Yellow Warning

To disable the warning please add console.disableYellowBox = true;

//Disable Yellow Warning Box
//https://aboutreact.com/disable-react-native-yellow-box-warnings/

//import React in our code
import React from 'react';

//import all the components we are going to use
import { View, LogBox } from "react-native";

LogBox.ignoreAllLogs();

const App = () => {
  return (
    <View> {/*Your Code will be here*/} </View>
  );
};

export default App;

Screenshot without Yellow Warning

So this is how to disable yellow warning box in React Native. If you have any problem or want to share anything then please comment below.

Hope you liked it. 🙂

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.