-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05_function-component.html
48 lines (41 loc) · 1.39 KB
/
05_function-component.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono:300,300i,700,700i|Roboto:300,300i,700,700i" rel="stylesheet">
<link rel="stylesheet" href="css/react.css">
<script src="https://unpkg.com/react@latest/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@latest/dist/react-dom.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
<script type="text/babel" data-presets="es2015,stage-2,react" data-plugins="transform-class-properties">
( function() {
/**
* MyButton
*
* React function component for stateless components
*
* @param {Object} props props that are passed to the component
*
* @return {Object} React Element Object
*/
const MyButton = ( props ) =>
<button className={ `btn btn-${props.type}` }>
{ props.caption }
</button>;
// render to Component:
ReactDOM.render(
<MyButton
caption="My Button Component"
type="danger"
/>,
document.querySelector( '#root' )
);
}() )
</script>
</body>
</html>