17
React Walk-Thru Santa Cruz JS Meetup 8th May 2015

React Walk-Thru - Santa Cruz JS, May 2015

Embed Size (px)

Citation preview

Page 1: React Walk-Thru - Santa Cruz JS, May 2015

React Walk-ThruSanta Cruz JS Meetup

8th May 2015

Page 2: React Walk-Thru - Santa Cruz JS, May 2015

Simon Sturmer Front-end Engineer @ Facebook

@simonsturmer

Page 3: React Walk-Thru - Santa Cruz JS, May 2015

–Some Guy on Twitter

“Building in React feels a little like Cheating.”

Page 4: React Walk-Thru - Santa Cruz JS, May 2015

Before we begin: ES6

• Template Strings

• Arrow Functions

• Destructuring Assignment

• Many more goodies…

Page 5: React Walk-Thru - Santa Cruz JS, May 2015

Template Strings

… also multi-line and backslash literals.

Page 6: React Walk-Thru - Santa Cruz JS, May 2015

Arrow Functions

Note the .bind(this) which is the most important part.

Page 7: React Walk-Thru - Santa Cruz JS, May 2015

Destructuring Assignment

the real win is using with function calls like require()

Page 8: React Walk-Thru - Santa Cruz JS, May 2015

… ok, now to the good stuff

Why React?

• Fresh way to build your UI

• Just the View layer

• Small API (can be learnt in a day)

• It’s an abstraction over the browser DOM

Page 9: React Walk-Thru - Santa Cruz JS, May 2015

React is different

react(data) → <View/>

• View is pure function of state

• Declarative

• Compositional

Page 10: React Walk-Thru - Santa Cruz JS, May 2015

Think of React like this…

…this is in-fact how react started.

Page 11: React Walk-Thru - Santa Cruz JS, May 2015

In React this would be:

oh right, JSX…

Page 12: React Walk-Thru - Santa Cruz JS, May 2015

JSX

• Not a templating library

• Just syntax sugar on top of JS

• Totally Optional

Page 13: React Walk-Thru - Santa Cruz JS, May 2015

Using State

Page 14: React Walk-Thru - Santa Cruz JS, May 2015

Composition

• Does not actually wrap one element with another

• Extend functionality, add defaults, etc.

Page 15: React Walk-Thru - Santa Cruz JS, May 2015

OK, let’s build…

Page 16: React Walk-Thru - Santa Cruz JS, May 2015

Who’s Using React• Netflix • AirBnB • PayPal • Yahoo • BBC • Pintrest • Instagram • WhatsApp • …and of course Facebook

Page 17: React Walk-Thru - Santa Cruz JS, May 2015

Simon Sturmer …and my little coder-in-the-making

@simonsturmer

I’ll post links to the slides and the demo code on Twitter.