This repository was archived by the owner on Apr 27, 2020. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
422 lines (373 loc) · 12.8 KB
/
Copy pathindex.html
File metadata and controls
422 lines (373 loc) · 12.8 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Introduction to ReactJS - for JSLuxembourg by Thierry Nicola</title>
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
<meta name="author" content="Hakim El Hattab">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/solarized.css" id="theme">
<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:200,300,400,500,600,700,900' rel='stylesheet'
type='text/css'>
<style>
h2 {
font-family: 'Source Code Pro', Arial;
}
</style>
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match(/print-pdf/gi) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName('head')[0].appendChild(link);
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>React.jS</h1>
<h3>Building User Interfaces</h3>
<p>
<small>for <a href="twitter.com/jsLuxembourg">@JSLuxembourg</a> by <a href="http://williambrownstreet.net">Thierry
Nicola</a> / <a href="http://twitter.com/littleiffel">@littleiffel</a>, Feb.2015
</small>
</p>
</section>
<section>
<h2>About me</h2>
<ul>
<li>
Thierry Nicola
</li>
<li>
<a href="http://williambrownstreet.net">My blog</a>
</li>
<li>
<a href="http://eevol.lu">My company</a> <br>
<small>Web-, iOS- and Android-Applications <i>(All Native)</i></small>
</li>
</ul>
</section>
<!-- Example of nested vertical slides -->
<section>
<h2>Agenda</h2>
<ol>
<li>
ReactJS
</li>
<li>
Goal of ReactJS
</li>
<li>
Getting Started with ReactJS
</li>
<li>
Demo with Live coding
</li>
</ol>
</section>
<section>
<h2>ReactJS</h2>
<ul>
<li>Javascript library for building user interfaces</li>
<li>By <a href="facebook.com">facebook.com</a></li>
<li>Initial Release ~ 2013</li>
<li>Current stable: v0.12.2</li>
<li>128kb</li>
<li>Used in Production by yahoo, instagram, facebook, Khan Academy, Netflix, Airbnb, Atlassian,...</li>
</ul>
</section>
<section>
<h2>Goal of ReactJs</h2>
<p>
Address common challenges in Single-Page Web Applications with data that changes over time
</p>
</section>
<section>
<h2>Why ReactJS might be interesting for you</h2>
<ul>
<li>ReactJS is not another MVC Framework, ReactJS is simply the V</li>
<li>Virtual DOM</li>
<li>One-way reactive Data flow</li>
<li>Build Web-Apps using <a href="https://facebook.github.io/flux/">FLUX</a></li>
<li><i>?Native ReactJS for iOS?</i></li>
</ul>
</section>
<section>
<section>
<h2>ReactJS - Just the UI</h2>
<blockquote cite="http://facebook.github.io/react/">
“Lots of people use React as the V in MVC. Since React makes no assumptions about the rest of your
technology stack, it's easy to try it out on a small feature in an existing project.”
</blockquote>
<p>
from <a href="http://facebook.github.io/react/">http://facebook.github.io/react/</a>
</p>
</section>
<section>
<h2>Components</h2>
<ul>
<li>A Component should ideally only do one thing</li>
<li>Components instead of Templates (NO HTML directives)</li>
<li>JSX<br><small>XML-LIKE SYNTAX EXTENSION TO ECMASCRIPT</small></li>
<li>Components have a state (of properties)</li>
<li>Components are organized in a hierarchy</li>
</ul>
<h4>An Example Component</h4>
<pre><code data-trim class="hljs js">
var HelloMessage = React.createClass({
render: function() {
return <div>Hello {this.props.name}</div>;
}
});
</code></pre>
</section>
</section>
<section>
<section>
<h2>ReactJS - Virtual DOM</h2>
<blockquote cite="http://facebook.github.io/react/">
React uses a virtual DOM diff implementation for ultra-high performance. It can also render on the server using
Node.js — no heavy browser DOM required.
</blockquote>
<p>
from <a href="http://facebook.github.io/react/">http://facebook.github.io/react/</a>
</p>
</section>
<section>
<h2>How ReactJS updates the DOM (Virtual DOM)</h2>
<ul>
<li>Axiom: "DOM manipulation is expensive"</li>
<ol>
<li>
Component.render generates in memory representation of the its view
</li>
<li>
From that representation a markup string is generated and injected into the document
</li>
<li>
On Data changes, <emph>Component.render</emph> is called again and a diff from current view to the new is made and a minimal set of required DOM changes is generated
</li>
<li>
Example: <a href="http://jsfiddle.net/fv6RD/3/">http://jsfiddle.net/fv6RD/3/</a>
</li>
</ol>
</ul>
</section>
</section>
<section>
<h2>ReactJS - Data flow</h2>
<blockquote cite="http://facebook.github.io/react/">
React implements one-way reactive data flow which reduces boilerplate and is easier to reason about than traditional data binding.
</blockquote>
<p>
from <a href="http://facebook.github.io/react/">http://facebook.github.io/react/</a>
</p>
</section>
<section>
<h2>Thinking in ReactJS</h2>
<ol>
<li>Break the UI into a component hierarchy</li>
<li>Build a static version in React (no interactivity but renders data)</li>
<li>Identify the minimal representation of UI state, </li>
<li>Identify where your state should live</li>
<li>Add inverse data flow (input -> state)</li>
</ol>
</section>
<section>
<h2>Coding a your first Component</h2>
<pre><code data-trim class="hljs js">
var HelloMessage = React.createClass({
render: function() {
return <div className="alert">Hello {this.props.name}</div>;
}
});
// Attach Component to DOM Node
React.render(<HelloWorld name='John' />, document.body);
</code></pre>
</section>
<section>
<h2>Stateful Component</h2>
<pre><code data-trim contenteditable class="hljs js">
var Timer = React.createClass({
getInitialState: function() {
return {secondsElapsed: this.props.init};
},
tick: function() {
this.setState({secondsElapsed: this.state.secondsElapsed + 1});
},
componentDidMount: function() {
this.interval = setInterval(this.tick, 1000);
},
componentWillUnmount: function() {
clearInterval(this.interval);
},
render: function() {
return (
<div>Seconds Elapsed: {this.state.secondsElapsed}</div>
);
}
});
React.render(<Timer init="100"/>, document.body);
</code></pre>
</section>
<section>
<section>
<h2>Forms</h2>
<ul>
<li>Controlled Forms</li>
<li>Uncontrolled Forms</li>
</ul>
</section>
<section>
<h2>Controlled Forms</h2>
<pre><code data-trim contenteditable class="hljs js">
var Form = React.createClass({
getInitialState: function() {
return {value: 'Hello!'};
},
handleChange: function(event) {
this.setState({value: event.target.value});
},
render: function() {
var value = this.state.value;
return <input type="text" value={value} onChange={this.handleChange} />;
}
})
</code></pre>
</section>
<section>
<h2>Uncontrolled Forms</h2>
<pre><code data-trim contenteditable class="hljs js">
var Form = React.createClass({
render: function() {
return <input type="text" defaultValue="Hello!" ref="myfield"/>;
}
})
</code></pre>
<p>
Access via <i>this.refs.myfield.getDOMNode().value</i>
</p>
</section>
</section>
<section>
<h2>Lets code</h2>
<ul>
<li>Installation: bower install react<br>
<small>Bower? Install bower: npm install bower<br>
NPM?</small></li>
</ul>
<pre><code data-trim contenteditable class="hljs html">
<html>
<head>
<script src="build/react.js"></script>
<script src="build/JSXTransformer.js"></script>
</head>
<body>
<div id="example"></div>
<script type="text/jsx">
var HelloMessage = React.createClass({
render: function() {
return <div>Hello {this.props.name}</div>;
}
});
React.render(<HelloMessage name="John" />, document.getElementById('example'));
</script>
</body>
</html>
</code></pre>
</section>
<section>
<h1>Demo</h1>
<ul>
<li>Static Mockup in ReactJS <a href="http://luxembourgjs.github.io/reactjs-intro/demos/index.html">LINK</a></li>
<li>With Form hooked up <a href="http://luxembourgjs.github.io/reactjs-intro/demos/index2.html">LINK</a></li>
</ul>
</section>
<section>
<h2>FLUX</h2>
<blockquote cite="http://facebook.github.io/flux/">
</p>Flux is the application architecture that Facebook uses for building client-side web applications. It complements React's composable view components by utilizing a unidirectional data flow. It's more of a pattern rather than a formal framework
</blockquote>
<p>
from <a href="http://facebook.github.io/flux/">http://facebook.github.io/flux/</a>
</section>
<section>
<h2>More</h2>
<ul>
<li><a href="http://facebook.github.io/react/docs/test-utils.html">Testing ReactJS</a></li>
<li>Pre Compile JSX offline <a href="http://facebook.github.io/react/docs/getting-started.html#offline-transform">Offline Transform</a></li>
<li>Two-Way Binding Helper <a href="http://facebook.github.io/react/docs/two-way-binding-helpers.html">ReactLink</a></li>
</ul>
</section>
<section>
<h2>Resources</h2>
<ul>
<li>ReactJS Homepage <a href="http://facebook.github.io/react">http://facebook.github.io/react</a></li>
<li><a href="http://egghead.io">Egghead.io</a></li>
<li><a href="https://github.com/enaqx/awesome-react">Awesome React Resources</a></li>
<li><a href="http://gaearon.github.io/react-hot-loader/">ReactJS Hot Loader</a> </li>
</ul>
</section>
<section style="text-align: left;">
<h1>THE END</h1>
<p>
Thanks for your attention!
</p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{
src: 'lib/js/classList.js', condition: function () {
return !document.body.classList;
}
},
{
src: 'plugin/markdown/marked.js', condition: function () {
return !!document.querySelector('[data-markdown]');
}
},
{
src: 'plugin/markdown/markdown.js', condition: function () {
return !!document.querySelector('[data-markdown]');
}
},
{
src: 'plugin/highlight/highlight.js', async: true, condition: function () {
return !!document.querySelector('pre code');
}, callback: function () {
hljs.initHighlightingOnLoad();
}
},
{src: 'plugin/zoom-js/zoom.js', async: true},
{src: 'plugin/notes/notes.js', async: true}
]
});
</script>
</body>
</html>