Mosh React Tutorial (part 12)

Pagination – Type Checking with Prop Type

What if the user passes something unexpected. Instead of an integer count. It passes a string “abc”.

In Pagination functional component, the string divides by integer. And thus, pagesCount becomes NaN. NaN gets calculated further and nothing comes of it.

npm i prop-types@15.6.2

pagination.jsx

Now let’s put a string, instead of an integer.
movies.jsx

In the console, we’ll get a warning: