forked from aladin002dz/Workshop-React-WordpressRestApi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEg4-Properties.html
38 lines (31 loc) · 1.54 KB
/
Eg4-Properties.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
<html>
<head>
<!-- Modules to run React -->
<!-- module to get React elements, mostly components -->
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<!-- module to render react elements into the web page -->
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<!-- module to use RJX and ES6 -->
<!--just to add some nice looking :) -->
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- where react elements will be rendered -->
<div id="root"></div>
<script type="text/babel">
/* React component using getting data from parent using "props" **********************************************/
class MyComponent extends React.Component {
/* every react component must have a render method to define the UI */
render() {
return <h1>Hello {this.props.name}, you live in {this.props.country}, you are a {this.props.work}!</h1>;
}
}
/* Rendering the React component into the DOM ****************************/
ReactDOM.render(
<MyComponent name="Mahfoudh" country="Algeria" work="Developer"/>,
document.getElementById("root")
);
</script>
</body>
</html>