'React Native: "setBackgroundColor is only available on android" warning on iOS

Like this:

enter image description here How can remove this warning?



Solution 1:[1]

As the warning states, setBackgroundColor style can only be applicable for Android version only.

You can solve this warning by specifying the style to apply only for Android version using below snippet.

import { Platform } from 'react-native' // on top of the file

style={{ setBackgroundColor : Platform.OS === 'android' ? 'blue' : null }} // style of the component

If you wish to disable all yellow warnings. Put below snippet in app.js after the imports and before class initialization.

//Disable warnings in both Android and IOS
console.disableYellowBox = true;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1