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

Every framework has a big idea

Slide 6

Slide 6 text

They don't just reinvent the wheel

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

Keep it simple

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

• Composition • Unidirectional Flow • Static mental model

Slide 12

Slide 12 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 13

Slide 13 text

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 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 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

But what's really going on?

Slide 24

Slide 24 text

JSX

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Slide 27

Slide 27 text

Virtual DOM

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

State changed! So what...

Slide 30

Slide 30 text

Imperative Programming Describe the transition between state

Slide 31

Slide 31 text

Declarative Programming Express the logic, not the flow

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

Let's talk about state

Slide 34

Slide 34 text

A component is given props A component manages state

Slide 35

Slide 35 text

A component is given props

Slide 36

Slide 36 text

A component manages state

Slide 37

Slide 37 text

That's basically it

Slide 38

Slide 38 text

Static Rendering Model

Slide 39

Slide 39 text

This is fast

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

Really fast

Slide 42

Slide 42 text

Static Mental Model

Slide 43

Slide 43 text

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

Slide 44

Slide 44 text

The DOM isn't the only rendering target

Slide 45

Slide 45 text

What is an isomorphic?

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

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

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

Page Load Boot App Server

Slide 50

Slide 50 text

React.renderToStaticMarkup(component)

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

How do I build real apps with this?

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

I thought this was supposed to be simple

Slide 56

Slide 56 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 57

Slide 57 text

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

Slide 58

Slide 58 text

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

Slide 59

Slide 59 text

App State Stimuli New state

Slide 60

Slide 60 text

Initial State Sound Jump()

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

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

Slide 66

Slide 66 text

On that note...

Slide 67

Slide 67 text

React injects a few constraints that yield powerful benefits

Slide 68

Slide 68 text

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

Slide 69

Slide 69 text

Hopefully I didn't scare you off with JSX :)

Slide 70

Slide 70 text

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

Slide 71

Slide 71 text

Iconography: User interface icon by Aziz, the Noun Project http://thenounproject.com/azisher 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 72

Slide 72 text

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