Browse Source

Add possible element types that accept propTypes (#386)

Co-authored-by: Sebastian Silbermann <silbermann.sebastian@gmail.com>
main
Eduard Rastoropov 5 years ago
committed by GitHub
parent
commit
b9c59963ff
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      content/docs/typechecking-with-proptypes.md

2
content/docs/typechecking-with-proptypes.md

@ -30,6 +30,8 @@ Greeting.propTypes = {
};
```
In this example, we are using a class component, but the same functionality could also be applied to function components, or components created by [`React.memo`](https://reactjs.org/docs/react-api.html#reactmemo) or [`React.forwardRef`](https://reactjs.org/docs/react-api.html#reactforwardref).
`PropTypes` exports a range of validators that can be used to make sure the data you receive is valid. In this example, we're using `PropTypes.string`. When an invalid value is provided for a prop, a warning will be shown in the JavaScript console. For performance reasons, `propTypes` is only checked in development mode.
### PropTypes {#proptypes}

Loading…
Cancel
Save