Skip to content

Commit 1fbb44c

Browse files
committed
who uses classes anymore?
1 parent 02192ed commit 1fbb44c

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

06-prop-types.html

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,20 @@
77
<script type="text/babel">
88
const rootElement = document.getElementById('root')
99

10-
class SayHello extends React.Component {
11-
static propTypes = {
12-
firstName: PropTypes.string.isRequired,
13-
lastName: PropTypes.string.isRequired,
14-
}
10+
function SayHello({firstName, lastName}) {
11+
return (
12+
<div>
13+
Hello {firstName} {lastName}!
14+
</div>
15+
)
16+
}
1517

16-
render() {
17-
const {firstName, lastName} = this.props
18-
return (
19-
<div>
20-
Hello {firstName} {lastName}!
21-
</div>
22-
)
23-
}
18+
SayHello.propTypes = {
19+
firstName: PropTypes.string.isRequired,
20+
lastName: PropTypes.string.isRequired,
2421
}
2522

26-
const element = <SayHello firstName="Jojo" lastName="Potatoes" />
23+
const element = <SayHello firstName="Sonic" lastName="The Hedgehog" />
2724

2825
ReactDOM.render(element, rootElement)
2926
</script>

0 commit comments

Comments
 (0)