64
KKbOX React.JS Conf & F8 Randy Lien

React.JS Conf & F8

Embed Size (px)

Citation preview

Page 1: React.JS Conf & F8

KKbOX

React.JS Conf & F8Randy Lien

Page 2: React.JS Conf & F8

KKbOX

Agenda

• Introduce React.js Conf

• Highlight

• Conclusion

• FAQ

Page 3: React.JS Conf & F8

KKbOX

Introduce React.js Conf

Page 4: React.JS Conf & F8

KKbOX

Page 5: React.JS Conf & F8

KKbOX

Page 6: React.JS Conf & F8

KKbOX

Page 7: React.JS Conf & F8

KKbOX

Page 8: React.JS Conf & F8

KKbOX

Page 9: React.JS Conf & F8

KKbOX

Page 10: React.JS Conf & F8

KKbOX

Page 11: React.JS Conf & F8

KKbOX

Page 12: React.JS Conf & F8

KKbOX

Introduction

• 2015/1/28 ~ 1/29 @Facebook HQ, CA

• 160~

• 18 sessions + 2 panels

• Tickets sold out in 1 minutes (3 waves)

Page 13: React.JS Conf & F8

KKbOX

Highlight

Page 14: React.JS Conf & F8

KKbOX

Highlight

• Performance

• Flux & Relay

• Component Communication

• React Native

Page 15: React.JS Conf & F8

KKbOX

Performance

Page 16: React.JS Conf & F8

KKbOX

The Keys to React Performance

• How to render

• When to render

Page 17: React.JS Conf & F8

KKbOX

Solutions

• Virtual DOM

• Optimistic re-rendering

Page 18: React.JS Conf & F8

KKbOX

Optimistic re-rendering• Pure Component (prop, state)

• Immutable data

• shouldComponentUpdate

• Only re-render when value is changed

• PureRenderMixin

Page 19: React.JS Conf & F8

KKbOX

Why Immutable?

• Immutable data is no side effect!

• Shared mutable state is the root of all evil - Pete Hunt

Page 20: React.JS Conf & F8

KKbOX

Page 21: React.JS Conf & F8

KKbOX

Why Immutable? (cont.)

• The reason why Om is faster than React

• Data or Value is immutable in Clojure

• Immutable + PureRenderMixin

Page 22: React.JS Conf & F8

KKbOX

facebook.github.io/immutable-js

Page 23: React.JS Conf & F8

KKbOX

Immutable.js

• It Implements immutable data structure in JavaScript

• Use the same algorithm with Clojure

Page 24: React.JS Conf & F8

KKbOX

PureRenderMixin implementationSimple but efficient

Page 25: React.JS Conf & F8

KKbOX

Flux & Relay

Page 26: React.JS Conf & F8

KKbOX

Flux & Relay

• Flux is an architecture

• Relay is designed for solving data fetching problem

Page 27: React.JS Conf & F8

KKbOX

Flux

• Unidirectional data flow

• Easy to debug

• It’s more of a pattern rather than a formal framework

Page 28: React.JS Conf & F8

KKbOX

Flux

Page 29: React.JS Conf & F8

KKbOX

Relay

• Relay is designed for solving data fetching problem

• Efficient

• Cache

• GraphQL

Page 30: React.JS Conf & F8

KKbOX

Relay Architecture

Page 31: React.JS Conf & F8

KKbOX

RelayContainer & Relay Store

Page 32: React.JS Conf & F8

KKbOX

Props coupling

Page 33: React.JS Conf & F8

KKbOX

Page 34: React.JS Conf & F8

KKbOX

Only modify 1 component

Page 35: React.JS Conf & F8

KKbOX

Page 36: React.JS Conf & F8

KKbOX

Component Communication

Page 37: React.JS Conf & F8

KKbOX

Component Communication

• It is a general problem

• Two scenarios

• Parent & Child

• No relationship

Page 38: React.JS Conf & F8

KKbOX

Parent & Child

• Pass props

• Use Callbacks

Page 39: React.JS Conf & F8

KKbOX

No Relationship• Global event system

• Flux

• Codecademy

• Adapter (broadcast)

• Channel (JS-CSP)

Page 40: React.JS Conf & F8

KKbOX

Adaptor

Page 41: React.JS Conf & F8

KKbOX

React Native

Page 42: React.JS Conf & F8

KKbOX

When ?

Page 43: React.JS Conf & F8

KKbOX

The reason to go native

Page 44: React.JS Conf & F8

KKbOX

React Native• No WebView, it uses JavaScript to control native UI.

• JavaScriptCore

• 3 pillars

• Touch Handling

• Native Components

• Style & Layout

• Reimplement Flex Box.

Page 45: React.JS Conf & F8

KKbOX

Benefits

Page 46: React.JS Conf & F8

KKbOX

Access to Platform ComponentsDifferent platforms have their own behaviours and styles

Page 47: React.JS Conf & F8

KKbOX

Instant UI change

Page 48: React.JS Conf & F8

KKbOX

Show errors on your face

Page 49: React.JS Conf & F8

KKbOX

Hard to figure out

Page 50: React.JS Conf & F8

KKbOX

Get benefits from existing solution

Page 51: React.JS Conf & F8

KKbOX

ComponentKit

Page 52: React.JS Conf & F8

KKbOX

Declarative

Page 53: React.JS Conf & F8

KKbOX

Same idea

Page 54: React.JS Conf & F8

KKbOX

The same conceptideally…

Page 55: React.JS Conf & F8

KKbOX

facebook Ads ManagerReact Native + Flux + Relay

Page 56: React.JS Conf & F8

KKbOX

facebook GroupsReact Native + Native Objective-C

Page 57: React.JS Conf & F8

KKbOX

native.reactjs.com

Page 58: React.JS Conf & F8

KKbOX

nuclide.ioImplement on top of Atom

Page 59: React.JS Conf & F8

KKbOX

Conclusion

Page 60: React.JS Conf & F8

KKbOX

Conclusion• Learn once, write anywhere

• React makes reusable components possible

• Look forward to Flux & Relay + GraphQL

• Tooling

• nuclide

• Jest

Page 61: React.JS Conf & F8

KKbOX

Conclusion (cont.)

• React Native is amazing but you still need to learn how native (Android/iOS) works

• Embrace Immutable data structure to reduce complexity

• It is time to use ES6 & ES2015

• Functional Programming is hot

• immutable data structure & functions composition

• #clojure

Page 62: React.JS Conf & F8

KKbOX

Trending

• React-inspired View - ComponentKit

• Flux architecture in Server side or App

• Functional Programming

Page 63: React.JS Conf & F8

KKbOX

Functional Programming• Operates on streaming and abstracts your behaviours

• Clojure

• LISP

• Immutable data structure

• ClojureScript

• #clojure

Page 64: React.JS Conf & F8

KKbOX

FAQ