I got a plenty of warnings while using Stylesheet in React Native as following image.
Warning on iOS simulator
How to suppress it?
The Yellow warning box in React Native can be both helpful and annoying. There are many errors that can be ignored but end up blocking necessary pieces of the application. To disable the yellow box place console. disableYellowBox = true; anywhere in your application.
Props and PropTypes are important mechanisms for passing read-only attributes between React components. We can use React props, short for properties, to send data from one component to another. If a component receives the wrong type of props, it can cause bugs and unexpected errors in your app.
isRequired means that props element defined is required to be passed from parent component. If you don't pass it, React will give you a warning message.
import React from 'react'; import PropTypes from 'prop-types'; function List(props) { const todos = props. todos. map((todo, index) => (<li key={index}>{todo}</li>)); return (<ul></ul>); } List. PropTypes = { todos: PropTypes.
There is no way to disable warnings for a specific component, but you can disable different types of warnings in your app. To disable all warnings, use:
console.disableYellowBox = true;
To disable only certain warnings that start with a given string, specify an array of prefixes to filter out:
console.ignoredYellowBox = ['Warning: ...'];
For example, for the warning in the question you could write:
console.ignoredYellowBox = [
'Warning: You are manually calling a React.PropTypes validation',
];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With