How to remove yellow warning box in React Native

Introduction :

Yellow warning box in react native is helpful if you want to know about any type of warnings. Especially, if you are using any third party library and if that library is using any deprecated API, it will show that over your phone screen. But it can be annoying at the same time if you already aware of that warning and you want to avoid it.

React native provides an easy way to disable this warning message. In this post, I will show you how to do that. These warnings are called YelloBox warnings and they are

console.disableYellowBox :

If we assign this variable as true, the yellow warning box is removed.

console.disableYellowBox = true;

Put it anywhere you want.

Remove specific warnings :

It is not always a good idea to remove all current and future warning messages. Instead, we can remove specific warnings by setting an array of prefixes of warnings like below :

import { YellowBox } from "react-native";
YellowBox.ignoreWarnings(["Warning: ..."]);

It will remove all the warning messages prefixed with any of the provided values in that array.