Slide 1

Slide 1 text

React

Slide 2

Slide 2 text

Nate Hunzaker Front-end Developer, Viget @natehunzaker

Slide 3

Slide 3 text

We build lots of user interfaces

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Every framework has a big idea

Slide 8

Slide 8 text

They don't just reinvent the wheel

Slide 9

Slide 9 text

“Backbone.js gives structure to web applications [...]”

Slide 10

Slide 10 text

“Ember.js is built for productivity. Designed with developer ergonomics in mind...”

Slide 11

Slide 11 text

Keep it simple

Slide 12

Slide 12 text

“We can only hope to make reliable those things in which we understand.” - Rich Hickey

Slide 13

Slide 13 text

• Composition • One way data flow • Static mental model

Slide 14

Slide 14 text

Compo(sition,nents) "React is all about building reusable components. In fact, with React the only thing you do is build components." - facebook.github.io/react

Slide 15

Slide 15 text

Encourage developers to break a user interface into small components.

Slide 16

Slide 16 text

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

• No templates • Strange syntax

Slide 24

Slide 24 text

“Templates separate technology, not concerns.” - Pete Hunt (formerly of Facebook)

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

JSX “The purpose of this specification is to define a concise and familiar syntax for defining tree structures with attributes.” http://facebook.github.io/jsx/

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

How does this work?

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

npm install babel npm install react-tools

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Slide 36

Slide 36 text

Virtual DOM

Slide 37

Slide 37 text

Build a DOM tree Compare to old state Get cheapest mutation path (with Levenshtein) Write new DOM (in batches) New state

Slide 38

Slide 38 text

State changed! So what...

Slide 39

Slide 39 text

Imperative Programming Describe the transition between state

Slide 40

Slide 40 text

Declarative Programming Express the logic, not the flow

Slide 41

Slide 41 text

Define Interface Change State • Each change in state flushes to the DOM • Properties are sent in one direction • No cascading updates

Slide 42

Slide 42 text

Let's talk about state

Slide 43

Slide 43 text

A component is given props A component manages state

Slide 44

Slide 44 text

A component is given props

Slide 45

Slide 45 text

A component manages state

Slide 46

Slide 46 text

That's kind of it

Slide 47

Slide 47 text

Static Rendering Model

Slide 48

Slide 48 text

This is fast

Slide 49

Slide 49 text

Holy Hot Modules! https://github.com/gaearon/react-hot-loader

Slide 50

Slide 50 text

Really fast

Slide 51

Slide 51 text

Static Mental Model

Slide 52

Slide 52 text

When you render to a virtual environment, the DOM becomes an implementation detail

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

What is an isomorphic?

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

React.render() is idempotent Same in, same out

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

React.renderToStaticMarkup

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

How do I build real apps with this?

Slide 63

Slide 63 text

Flux “Flux [...] complements React's composable view components by utilizing a unidirectional data flow.” http://facebook.github.io/flux/

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

I thought you said this was simple

Slide 66

Slide 66 text

Job Queue State State State I want to create a widget Ready a widget! I can totally do that! Ch-ch-ch-ch- changes I love David Bowie!

Slide 67

Slide 67 text

Flux Formal Capacitor: A demo isomorphic Flux app https://github.com/vigetlabs/capacitor

Slide 68

Slide 68 text

Flux Fun http://www.natehunzaker.com/yappy-bird/

Slide 69

Slide 69 text

App State Stimuli New state

Slide 70

Slide 70 text

Initial State Sound Jump()

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

NuclearJS https://github.com/optimizely/nuclear-js Yahoo Flux https://github.com/yahoo/flux-examples Om (Clojurescript) https://github.com/swannodette/om

Slide 76

Slide 76 text

On that note...

Slide 77

Slide 77 text

React injects a few constraints that yield powerful benefits

Slide 78

Slide 78 text

By focusing on composability and a single direction flow of data, we can greatly simplify our apps

Slide 79

Slide 79 text

Hopefully you didn't ignore me after the JSX :)

Slide 80

Slide 80 text

Thanks! Nate Hunzaker Front-end Developer, Viget @natehunzaker

Slide 81

Slide 81 text

Iconography: User interface icon by Aziz, the Noun Project http://thenounproject.com/azisher JavaScript Logo: https://github.com/voodootikigod/logo.js General React Concepts: React Homepage http://facebook.github.io/react/ JSX Specification http://facebook.github.io/jsx/ Rethinking Best Practices, Pete Hunt: https://www.youtube.com/watch?v=x7cQ3mrcKaY Decomplexifying Code with React, Steven Luscher: https://www.youtube.com/watch?v=rI0GQc__0SM An Introduction to ReactJS, James Pierce https://www.youtube.com/watch?v=m2fuO2wl_3c Flux Flux Homepage http://facebook.github.io/flux/ Examples React Fun https://github.com/nhunzaker/react-fun React Animatable https://github.com/nhunzaker/react- animatable An Isomorphic Chart https://github.com/nhunzaker/an- isomorphic-chart Capacitor https://github.com/vigetlabs/capacitor Yappy Bird https://github.com/nhunzaker/yappy-bird

Slide 82

Slide 82 text

react-router: the best router https://github.com/rackt/react-router