2021-06-08 14:23:48 +02:00
If the type of a ``++props++`` property is not defined there is a great chance one will wrongly use the value returned by the property and generate a not expected behavior of the application.
== Noncompliant Code Example
----
class Rating extends React.Component {
render() {
return ( <div>{this.props.rating}</div> );
}
}
----
== Compliant Solution
----
import PropTypes from 'prop-types';
class Rating extends React.Component {
render() {
return ( <div>{this.props.rating}</div> );
}
}
Rating.propTypes = {
rating: PropTypes.number.isRequired
};
----
ifdef::env-github,rspecator-view[]
2021-06-08 15:52:13 +02:00
'''
2021-06-08 14:23:48 +02:00
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]