Sometimes, we may run into the "Don’t Call PropTypes Warning" when we’re developing React apps.
In this article, we’ll look at how to fix the "Don’t Call PropTypes Warning" when we’re developing React apps.
Fix the "Don’t Call PropTypes Warning" When Developing React Apps
To fix the "Don’t Call PropTypes Warning" when we’re developing React apps, we shouldn’t call any function that are required by PropTypes
.
For instance, we shouldn’t write anything like:
const apiShape = PropTypes.shape({
body: PropTypes.object,
statusCode: PropTypes.number.isRequired
}).isRequired;
const error = apiShape(json, 'response');
We can’t call the function returned by PropTypes.shape
directly.
Conclusion
To fix the "Don’t Call PropTypes Warning" when we’re developing React apps, we shouldn’t call any function that are required by PropTypes
.