With react hooks coming, should we use prop-types for React custom hooks e.g,
import React from \'react\';
import PropTypes from \'prop-types\';
const u
No. React doesn't validate custom hooks or in-built hooks props.
Look here for updateFunctionComponent, It validates prop types using checkPropTypes
for a react component and then render it with hooks i.e. check out renderWithHooks
.
Now if you check here in renderWithHooks method, It updates the dispatcher and calls your functional component which in turn calls your custom hook, since it's just another function call inside your functional component.
Your custom hook will call in-built hooks. You can check the implementation here . Based on type of dispatcher it will call built-in hooks.
If you search checkPropTypes
in the whole file you won't find the validation logic or prop-types/checkPropTypes
dependency which is used to validate the prop types.
Here is some nice article about how react hooks works