forked from kay-is/react-from-zero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
15-simple-integration.html
40 lines (32 loc) · 1.29 KB
/
15-simple-integration.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
<!doctype html>
<title>15 Simple Integration - React From Zero</title>
<script src="https://unpkg.com/[email protected]/umd/react.development.js"></script>
<script src="https://unpkg.com/[email protected]/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="https://unpkg.com/[email protected]/min/moment.min.js">
// Most of the time we have to use third party libraries
// in our applications. Here we integrate a simple one
// for date handling and use it with React. It doesn"t
// use the DOM so it can be integrated fairly easy.
</script>
<div id="app"></div>
<script type="text/babel">
// Simple libraries that are called synchronous can used
// directly in JSX with the help of {}, since they are
// just function calls
var DateToday = function() {
return <span>{moment().format("DD.MM.YYYY")}</span>
}
var tomorrow = moment().add(1, "day")
// Nothing exciting happening here, just calling the library
// and displaying its return values. First with some
// elements, then used inside of a component.
var reactElement =
<div>
<h1 style={{textAlign:"center"}}>
Tomorrow is {tomorrow.format("MMMM")} the {tomorrow.format("Do")}
</h1>
<DateToday/>
</div>
ReactDOM.render(reactElement, document.getElementById("app"))
</script>