It is used to check types
Example:
App.js
import React from 'react';
import PropTypes from 'prop-types';
class App extends React.Component {
render() {
return (
<h1>Hello, {this.props.name}</h1>
);
}
}
App.propTypes = {
name: PropTypes.string
};
export default App;
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App name="Shark"/>
</React.StrictMode>,
document.getElementById('root')
);