-
Notifications
You must be signed in to change notification settings - Fork 0
/
07-prop-types.html
29 lines (26 loc) · 1004 Bytes
/
07-prop-types.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<body>
<div id="root"></div>
<script src="https://unpkg.com/react@16.12.0/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@16.12.0/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@babel/standalone@7.8.3/babel.js"></script>
<script src="https://unpkg.com/prop-types@15.6.1/prop-types.js"></script>
<script type="text/babel">
// React Gives method to check proptypes which development
// This Proptypes are ignored in production mode
// We can also pass default value in props
const rootElement = document.getElementById("root");
function SayHello({ firstName, lastName }) {
return (
<div>
Hello {firstName} {lastName}!
</div>
);
}
SayHello.propTypes = {
firstName: PropTypes.string.isRequired,
lastName: PropTypes.string.isRequired,
};
const element = <SayHello firstName={false} />;
ReactDOM.render(element, rootElement);
</script>
</body>