34
Learning React - I Senior Front-End Manager Mitch Chen

Learning React - I

Embed Size (px)

DESCRIPTION

Introduce to React

Citation preview

Page 1: Learning React - I

Learning React - ISenior Front-End Manager

Mitch Chen

Page 2: Learning React - I

Outline• Showcase

• Overview

• Tutorial

• Where To Go From Here

• Q & A

Page 3: Learning React - I

Showcase• Facebook

• Instagram

• Khan Academy

• The New York Times

• Mobile Web App

Page 5: Learning React - I

Instagram

Page 6: Learning React - I

Khan Academy

Page 8: Learning React - I
Page 9: Learning React - I
Page 10: Learning React - I

Overview• What is React?

• Why React Rock?

• Components, Not Templates

• Re-render

• Virtual DOM

Page 11: Learning React - I

What Is React ?

Page 12: Learning React - I

• A Library for creating user interfaces

• Not yet another JS framework

• Renders your UI and responds to Events

• Aka: The V in MVC

Page 13: Learning React - I

Why React Rock?

Page 14: Learning React - I

• Battle-tested on Facebook and Instagram

• Building Large Applications with data that changes over time

• Components are so Encapsulated, make code Reuse, Testing and Separation of Concerns easy

• Browser support back to IE8

Page 15: Learning React - I

Components, Not Templates

Page 16: Learning React - I

• Separation of Concerns: Reduce Coupling, increase Cohesion

• Components are the right way to separate concerns

• Display Logic and Markup are highly Cohesive:They both show the UI

• React component use Expressive power of programming language(JSX) to build UIs

• React component:A highly Cohesive building block for UIs Loosely Coupled with other components

Page 17: Learning React - I

• Components are Reusable, Composable and Unit Testable

• Build many simple components that does one thing really well

• Then compose them into a bigger functional unit

• Which allows you to structure the application better with more flexibility

Page 18: Learning React - I
Page 19: Learning React - I
Page 20: Learning React - I

Re-Render

Page 21: Learning React - I

• State has data you own, Props has data you borrow

• When the state(data) changes, React Re-renders the Entire Component

• No magical data binding

• No model dirty checking

• No more explicit DOM operations: Everything is declarative

Page 22: Learning React - I

ReactJS AngularJSv.s.

Page 23: Learning React - I

Data flow when a user event results in a DOM update

Page 24: Learning React - I

Virtual DOM

Page 25: Learning React - I

Traditional Web App

React Web App

Page 26: Learning React - I

• Makes re-rendering on every change fast

• Computes minimal DOM operations

• Batched reads and writes for optimal DOM performance

• Usually faster than manual DOM operations

• 60fps, even in a UIWebView on the iPhone

Page 27: Learning React - I
Page 28: Learning React - I

React V.S. Doom 3

Doom 3

React

Page 29: Learning React - I

On Every Update…• React builds a new virtual DOM

subtree

• Diff it with the old one

• Computes the minimal set of DOM mutations and puts them in a queue

• Batch executes all updates

Page 30: Learning React - I

Tutorial• Example: Youtube Most Popular

Page 31: Learning React - I
Page 32: Learning React - I

Where To Go From Here• React JSX

• State and Props

• Component Specifications and Lifecycle

• Communicate Between Components

• Flux v.s. MVC

• ……

Page 33: Learning React - I

Q & A

Page 34: Learning React - I

Referencehttp://facebook.github.io/react/

http://www.slideshare.net/floydophone/react-preso-v2

http://www.funnyant.com/reactjs-what-is-it/

http://calendar.perfplanet.com/2013/diff/

http://lincolnloop.com/blog/architecting-your-app-react-part-1/