-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
744 lines (644 loc) · 23.1 KB
/
index.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
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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="twitter:widgets:csp" content="on">
<title>reveal.js - The HTML Presentation Framework</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/moon.css" id="theme">
<link rel="stylesheet" href="css/custom.css">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/solarized_light.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]-->
<!-- React for inline demos -->
<script src="http://fb.me/react-0.12.2.js"></script>
<script src="http://fb.me/JSXTransformer-0.12.2.js"></script>
<!-- <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> -->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section data-background="img/MissoulaJS-GDG-520x240.png" data-background-repeat="repeat" data-background-size="300px">
</section>
<section>
<h1>Intro to React</h1>
<p>
<small>Presented by <a href="http://fisher.io">Lance Fisher</a> / <a href="http://twitter.com/lancefisher">@lancefisher</a></small>
</p>
</section>
<section>
<h2>React</h2>
<p>
A JavaScript library from Facebook for building user interfaces
</p>
<p>
<a href="http://facebook.github.io/react/">http://facebook.github.io/react/</a>
</p>
</section>
<section>
<h1>Components</h1>
<p>
In React, user interfaces are built with components.
</p>
</section>
<section>
<section data-transition="none">
<h2>What's a Component?</h2>
<img class="mockup" src="/img/todo-mockup-1.png">
<p class='mono'> </p>
</section>
<section data-transition="none">
<h2>What's a Component?</h2>
<img class="mockup" src="/img/todo-mockup-2.png">
<p class='mono'>AppComponent</p>
</section>
<section data-transition="none">
<h2>What's a Component?</h2>
<img class="mockup" src="/img/todo-mockup-3.png">
<p class='mono'>AddItemComponent</p>
</section>
<section data-transition="none">
<h2>What's a Component?</h2>
<img class="mockup" src="/img/todo-mockup-4.png">
<p class='mono'>TodoListComponent</p>
</section>
<section data-transition="none">
<h2>What's a Component?</h2>
<img class="mockup" src="/img/todo-mockup-5.png">
<p class='mono'>TodoListItemComponent</p>
</section>
</section>
<section>
<section data-transition="none">
<h2 class="mono">HelloWorldComponent</h2>
<pre><code contenteditable>
<div id="container"></div>
<script src="http://fb.me/react-0.12.2.js"></script>
<script src="http://fb.me/JSXTransformer-0.12.2.js"></script>
<script type="text/jsx">
var HelloMessage = React.createClass({
render: function() {
return <div>Hello {this.props.name}!</div>;
}
});
var container = document.getElementById('container')
React.render(<HelloMessage name="world" />,
container);
</script>
</code></pre>
<!-- HelloWorldComponent Demo -->
<div id="container-1"></div>
<script type="text/jsx">
var HelloMessage = React.createClass({
render: function() {
return <div>Hello {this.props.name}!</div>;
}
});
var container = document.getElementById('container-1');
React.render(<HelloMessage name="world" />,
container);
</script>
</section>
<section data-transition="none">
<h2 class="mono">HelloWorldComponent</h2>
<pre><code contenteditable>
<div id="container"></div>
<script src="http://fb.me/react-0.12.2.js"></script>
<script>
var HelloMessage = React.createClass({
render: function() {
return React.createElement("div", null, "Hello ",
this.props.name, "!");
}
});
var container = document.getElementById('container')
React.render(React.createElement(HelloMessage, {name: "world"}),
container);
</script>
</code></pre>
<!-- HelloWorldComponent Demo -->
<div id="container-2"></div>
<script>
var HelloMessage = React.createClass({
render: function() {
return React.createElement("div", null, "Hello ",
this.props.name, "!");
}
});
var container = document.getElementById('container-2')
React.render(React.createElement(HelloMessage, {name: "world"}),
container);
</script>
</section>
</section>
<section>
<h2>JSX</h2>
<p>Markup in your JavaScript!</p>
<pre><code contenteditable>
var HelloMessage = React.createClass({
render: function() {
return <div>Hello {this.props.name}!</div>;
}
});
</code></pre>
</section>
<section>
<section>
<blockquote class="twitter-tweet" lang="en"><p>Does JSX feel like PHP files in the 90's to anyone else? HTML and PHP mashed into a single file. Didn't we decide that wasn't great?</p>— Roman Shtylman (@defunctzombie) <a href="https://twitter.com/defunctzombie/status/569184791083536385">February 21, 2015</a></blockquote>
</section>
<section>
<blockquote class="twitter-tweet" data-cards="hidden" lang="en"><p>Some aspects of <a href="https://twitter.com/hashtag/ReactJS?src=hash">#ReactJS</a> I hate (JSX), but some are really awesome. Virtual DOM, now native apps <a href="https://t.co/7JGbOvxovk">https://t.co/7JGbOvxovk</a></p>— Evgeniy OZ (@eugeniyoz) <a href="https://twitter.com/eugeniyoz/status/560635324125040640">January 29, 2015</a></blockquote>
</section>
<section>
<blockquote class="twitter-tweet" lang="en"><p>Just a reminder the new hotness of JSX is catching up to VisualBasic in 2008 <a href="http://t.co/v3WNQEfuII">http://t.co/v3WNQEfuII</a> (confer javascript vs. vbscript)</p>— Marc Brooks (@IDisposable) <a href="https://twitter.com/IDisposable/status/570350088628805633">February 24, 2015</a></blockquote>
</section>
<section>
<blockquote class="twitter-tweet" lang="en"><p>do I know anyone who uses React? do you get over how gross JSX is? because it’s gross and I don’t want it</p>— fleetwood windows (@ruhee_) <a href="https://twitter.com/ruhee_/status/573277622517563392">March 5, 2015</a></blockquote>
</section>
<section>
<blockquote class="twitter-tweet" lang="en"><p><a href="https://twitter.com/mmatuzak">@mmatuzak</a> I tried to hate jsx (I tried hard!) and failed. I don't love it, but I get it.</p>— Ian Bicking (@ianbicking) <a href="https://twitter.com/ianbicking/status/507378348654604289">September 4, 2014</a></blockquote>
</section>
</section>
<section>
<h2>JSX</h2>
<p>A Simple Syntax Transform from XML to JavaScript</p>
<pre><code contenteditable>
$ npm install -g react-tools
$ jsx . /out
</code></pre>
</section>
<section>
<h2>The render method</h2>
<ul>
<li>Pure Function</li>
<li>Don't change props or state</li>
<li>Return hierarchy of elements</li>
</ul>
</section>
<section>
<h2>The render method</h2>
<pre><code contenteditable>
var HelloMessage = React.createClass({
render: function() {
var name = 'Mr. ' + this.props.name;
return (
<div>
Hello {name}!
</div>
);
}
});
</code></pre>
<!-- Render method Demo -->
<div id="container-3"></div>
<script type="text/jsx">
var HelloMessage = React.createClass({
render: function() {
var name = 'Mr. ' + this.props.name;
return (
<div>
Hello {name}!
</div>
);
}
});
var container = document.getElementById('container-3');
React.render(<HelloMessage name="world" />,
container);
</script>
</section>
<section>
<h2>props and state</h2>
<p>Two types of model data</p>
</section>
<section>
<h2>props and state</h2>
<ul>
<li>Set <span class="mono">props</span> from the outside</li>
<li>Set <span class="mono">state</span> from the inside</li>
<li>Try to avoid <span class="mono">state</span></li>
</ul>
</section>
<section>
<h2>props and state</h2>
<pre><code contenteditable>
var HelloMessage = React.createClass({
componentWillMount: function() {
this.setState({ time: new Date().toLocaleTimeString() });
self = this;
setInterval(function() {
self.setState({ time: new Date().toLocaleTimeString() });
}, 1000);
},
render: function() {
return (
<div>
Hello! The time is {this.state.time}.
</div>
);
}
});
</code></pre>
<!-- Render method Demo -->
<div id="container-4"></div>
<script type="text/jsx">
var HelloMessage = React.createClass({
componentWillMount: function() {
this.setState({
time: new Date().toLocaleTimeString()
});
self = this;
setInterval(function() {
self.setState({
time: new Date().toLocaleTimeString()
});
}, 1000);
},
render: function() {
return (
<div>
Hello! The time is {this.state.time}.
</div>
);
}
});
var container = document.getElementById('container-4');
React.render(<HelloMessage name="world" />,
container);
</script>
</section>
<section>
<h2>Component Lifecycle</h2>
<ul>
<li>Mounting</li>
<li>Updating</li>
<li>Unmounting</li>
</ul>
</section>
<section>
<h2>Component Lifecycle - Mounting</h2>
<pre><code contenteditable>
var HelloMessage = React.createClass({
componentWillMount: function() {
},
componentDidMount: function() {
}
});
</code></pre>
</section>
<section>
<section data-transition="none">
<h2>Component Lifecycle - Updating</h2>
<pre><code contenteditable>
var HelloMessage = React.createClass({
componentWillReceiveProps: function(nextProps) {
},
shouldComponentUpdate(): function(nextProps, nextState) {
}
});
</code></pre>
</section>
<section data-transition="none">
<h2>Component Lifecycle - Updating</h2>
<pre><code contenteditable>
var HelloMessage = React.createClass({
componentWillReceiveProps: function(nextProps) {
this.setState({
profiting: nextProps.stockPrice > this.props.stockPrice
});
},
shouldComponentUpdate: function(nextProps, nextState) {
return nextProps.immutable !== this.props.immutable;
}
});
</code></pre>
</section>
</section>
<section>
<h2>Component Lifecycle - Updating</h2>
<pre><code contenteditable>
var HelloMessage = React.createClass({
componentWillUpdate: function(nextProps, nextState) {
//too late to set state here
},
componentDidUpdate: function() {
}
});
</code></pre>
</section>
<section>
<section data-transition="none">
<h2>Component Lifecycle - Unmounting</h2>
<pre><code contenteditable>
var HelloMessage = React.createClass({
componentWillUnmount: function() {
// Clean up stuff here
}
});
</code></pre>
</section>
<section data-transition="none">
<h2>Component Lifecycle - Unmounting</h2>
<pre><code contenteditable>
var HelloMessage = React.createClass({
componentWillUnmount: function() {
// That interval we started...
clearInterval(this.state.intervalId);
}
});
</code></pre>
</section>
</section>
<section>
<h2>Component API</h2>
<p>This is the rest of it!</p>
<pre><code contenteditable>
var HelloMessage = React.createClass({
getInitialState: function() {
},
getDefaultProps: function() {
},
propTypes: [
],
mixins: [
],
statics: {
}
});
</code></pre>
</section>
<section>
<h2>Events</h2>
<ul>
<li>SyntheticEvent</li>
<li>Autobinding</li>
<li>Event Delegation</li>
<li>Same in all browsers</li>
</ul>
</section>
<section>
<h2>Events</h2>
<pre><code contenteditable>
var HelloMessage = React.createClass({
getInitialState: function() {
return { clicks: 0 };
},
handleClick: function(e) {
e.preventDefault();
this.setState({ clicks: this.state.clicks + 1 });
},
render: function() {
return (
<div>
<a onClick={this.handleClick}>Click Me!</a>
&nbsp; Clicks: {this.state.clicks}
</div>
);
}
});
</code></pre>
<!-- Render method Demo -->
<div id="container-5"></div>
<script type="text/jsx">
var HelloMessage = React.createClass({
getInitialState: function() {
return { clicks: 0 };
},
handleClick: function(e) {
e.preventDefault();
this.setState({
clicks: this.state.clicks + 1
});
},
render: function() {
return (
<div>
<a onClick={this.handleClick}>Click Me!</a>
Clicks: {this.state.clicks}
</div>
);
}
});
var container = document.getElementById('container-5');
React.render(<HelloMessage name="world" />,
container);
</script>
</section>
<section>
<h2>Forms</h2>
<ul>
<li>Controlled Components - value</li>
<li>Uncontrolled Components - defaultValue</li>
</ul>
</section>
<section>
<h2>Forms - Controlled Components</h2>
<pre><code contenteditable>
var HelloMessage = React.createClass({
getInitialState: function() { return { name: '' }; },
handleChange: function(e) {
this.setState({ name: e.target.value });
},
render: function() {
var name = this.state.name;
var message = name ? 'Hi, ' + name : '';
return (
<div>
<input type="text"
value={name}
onChange={this.handleChange} /><br/>
{message}
</div>
);
}
});
</code></pre>
<!-- Render method Demo -->
<div id="container-6"></div>
<script type="text/jsx">
var HelloMessage = React.createClass({
getInitialState: function() { return { name: '' }; },
handleChange: function(e) {
this.setState({
name: e.target.value
});
},
render: function() {
var name = this.state.name;
var message = name ? 'Hi, ' + name : '';
return (
<div>
<input type="text"
value={name}
onChange={this.handleChange} /><br/>
{message}
</div>
);
}
});
var container = document.getElementById('container-6');
React.render(<HelloMessage name="world" />,
container);
</script>
</section>
<section>
<h2>Reusing Components</h2>
<pre><code contenteditable>
var HelloMessage = React.createClass({
render: function() {
return <div>Howdy, {this.props.name}!</div>;
}
});
var HelloPeople = React.createClass({
render: function() {
return (
<div>
<HelloMessage name="Weasel" />
<HelloMessage name="Woodpecker" />
<HelloMessage name="Putin" />
</div>
);
}
});
</code></pre>
<!-- Render method Demo -->
<div id="container-7"></div>
<script type="text/jsx">
var HelloMessage = React.createClass({
render: function() {
return <div>Howdy, {this.props.name}!</div>;
}
});
var HelloPeople = React.createClass({
render: function() {
return (
<div>
<HelloMessage name="Weasel" />
<HelloMessage name="Woodpecker" />
<HelloMessage name="Putin" />
</div>
);
}
});
var container = document.getElementById('container-7');
React.render(<HelloPeople />,
container);
</script>
</section>
<section>
<h2>Reusing Components</h2>
<pre><code contenteditable>
var HelloMessage = React.createClass({
render: function() {
return <div>Howdy, {this.props.name}!</div>;
}
});
var HelloPeople = React.createClass({
render: function() {
var people = ['Weasle', 'Woodpecker', 'Putin'];
var messages = people.map(function(p) {
return <HelloMessage name={p} />;
})
return (
<div>{messages}</div>
);
}
});
</code></pre>
<!-- Render method Demo -->
<div id="container-8"></div>
<script type="text/jsx">
var HelloMessage = React.createClass({
render: function() {
return <div>Howdy, {this.props.name}!</div>;
}
});
var HelloPeople = React.createClass({
render: function() {
var people = ['Weasle', 'Woodpecker', 'Putin'];
var messages = people.map(function(p) {
return <HelloMessage name={p} />;
});
return (
<div>{messages}</div>
);
}
});
var container = document.getElementById('container-8');
React.render(<HelloPeople />,
container);
</script>
</section>
<section>
<h2>The Virtual DOM</h2>
<p>What makes react fast.</p>
</section>
<section>
<h2>Next Steps...</h2>
</section>
<section>
<h2>Use a module/build system</h2>
<ul>
<li><a href="http://browserify.org/">browserify</a></li>
<li><a href="http://webpack.github.io/">webpack</a></li>
<li><a href="http://gaearon.github.io/react-hot-loader/">React Hot Loader</a> is available for webpack</li>
</ul>
</section>
<section>
<h2>React Developer Tools</h2>
<p><a href="https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en">Chrome extension</a> to help debug react components.</p>
</section>
<section>
<h2>Structure a Flux App</h2>
<ul>
<li>Maintain app state in "stores"</li>
<li>Control changes to state</li>
</ul>
</section>
<section>
<h2>React Native</h2>
<p>React Native is coming this year. <a href="https://www.youtube.com/watch?v=7rDsRXj9-cU">Watch the video.</a></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>
<script src="node_modules/react/dist/react.min.js"></script>
</body>
</html>