Categories
React Answers

How to Fix the “Don’t Call PropTypes Warning” When Developing React Apps?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *