I am new to prop validation in React.
Let's say that I have the following code, where the validation is focused on the title prop as a string
import PropTypes from "prop-types";
function Component (props) {
[...]
}
Component.propTypes = {
title: PropTypes.string
}
Component.defaultProps = {
title: 'Foo'
}
If the value of the title prop happens to be a number instead, the component will continue its lifecycle with the wrong prop, just after throwing a Warning in the console.
Is there a built in way or a workaround to make that invalid prop get a fallback value or simply the default value?