React - - PowerPoint PPT Presentation

react
SMART_READER_LITE
LIVE PREVIEW

React - - PowerPoint PPT Presentation

React A"JavaScript"Library"For"Building"User"Interfaces React&is&not&FRP [Func&onal]+Reac&ve+programming+is+programming+with+ asynchronous+data+streams. !!"Andr"Staltz 1 1


slide-1
SLIDE 1

React

A"JavaScript"Library"For"Building"User"Interfaces

slide-2
SLIDE 2

React&is&not&FRP

[Func&onal]+Reac&ve+programming+is+programming+with+ asynchronous+data+streams. !!"André"Staltz1

1"The"introduc.on"to"Reac.ve"Programming"you've"been"missing

slide-3
SLIDE 3

Component(Based

It's%components%all%the%way%down!

slide-4
SLIDE 4

Func%onal)*)Declara%ve)UI

Impera've)<+>)Declara've

slide-5
SLIDE 5

Func%onal)*)Declara%ve)UI

slide-6
SLIDE 6

Virtual(DOM

The$UI$is$first$rendered$to$a$virtual$DOM,$then$a$minimal$and$ efficient$diff$is$applied$to$the$actual$DOM$to$update$the$visible$UI.

slide-7
SLIDE 7

(aside)(JSX(Syntax

// JSX as authored <div className="app"> <h2>Hello World</h2> <p>Welcome to {this.props.appName}</p> <UserList users={activeUsers} /> </div>

// output JS React.createElement("div", {className: "app"}, React.createElement("h2", null, "Hello World"), React.createElement("p", null, "Welcome to ", this.props.appName), React.createElement(UserList, {users: activeUsers}) )

slide-8
SLIDE 8

Sample'App

slide-9
SLIDE 9

Sample'App

  • App$component$(blue)
slide-10
SLIDE 10

Sample'App

  • App$component$(blue)
  • User$list$component$(green)
slide-11
SLIDE 11

Sample'App

  • App$component$++$blue
  • User$list$component$++$green
  • Profile$component(s)$++$red
slide-12
SLIDE 12

User%profile%component

var Profile = React.createClass({ githubUrl: function() { return "https://github.com/" + this.props.user.github; }, render: function() { return ( <li className="user"> <a href={this.githubUrl()}> {this.props.user.name} on github </a> </li> ) } });

slide-13
SLIDE 13

User%List%Component

var UserList = React.createClass({ renderUser: function(user) { return <Profile user={user} /> }, render: function() { return ( <ul> {this.props.users.map(this.renderUser)} </ul> ) } })

slide-14
SLIDE 14

App#Component

var App = React.createClass({ render: function() { return ( <div className="app"> <h1>Active Users</h1> <p>{this.props.users.length} active users</p> <UserList users={this.state.users} /> </div> ) } })

slide-15
SLIDE 15

Boot$The$App

var users = [ { name: "Chris", github: "christoomey" }, { name: "Joe", github: "jferris" }, { name: "Ben", github: "r00k" }, { name: "Chad", github: "cpytel" } ]; React.renderComponent( <App users={users} />, document.getElementById('content') );

slide-16
SLIDE 16

Rethinking)Best)Prac0ces

  • Render&the&world"#"Re#render"everything"on"any"change"Re#

render"the"en2re"app"(in"memory)"on"all"changes,"then"efficiently" update"the"UI"to"match.

  • Sepera/on&of&Concerns"#"Rather"than"pulling"out"templates,"

separate"in"terms"of"components

  • Hide&the&DOM"#"The"Virutal"DOM"abstracts"away"the"harsh"

reality"of"the"DOM"API"and"allows"you"to"focus"on"your"app. From%Pete%Hunt's%presenta0on

slide-17
SLIDE 17

The$right$abstrac-on

Abstrac(ng+away+the+DOM+has+lead+to+some+very+impressive+work+ in+short+(me

  • canvas'render'target
  • Ne.lix's'gibbon'widget'system
  • Server'side'/'isometric'rendering':
  • react'na;ve
slide-18
SLIDE 18

Flipboard's,Canvas

In#search#of#60fps#on#mobile. React&Canvas&adds&the&ability&for&React& components&to&render&to&<canvas>& rather&than&DOM.

slide-19
SLIDE 19

Ne#lix'Gibbon

Ne#lix's)Gibbon)widget)system)is)an) alterna6ve)rendering)engine)that)takes)the) place)of)the)DOM,)while)s6ll)using)React.

slide-20
SLIDE 20

Server%Side

Since&the&DOM&is&abstracted&away,&react&can&run&in&Node&and& render&to&a&string!

slide-21
SLIDE 21

React&Na(ve

slide-22
SLIDE 22

The$Right$Abstrac/on

It's%worth%no+ng%that%we're%not%chasing%“write%once,%run%anywhere.”% Different%pla;orms%have%different%looks,%feels,%and%capabili+es,%and% as%such,%we%should%s+ll%be%developing%discrete%apps%for%each% pla;orm,%but%the%same%set%of%engineers%should%be%able%to%build% applica+ons%for%whatever%pla;orm%they%choose,%without%needing%to% learn%a%fundamentally%different%set%of%technologies%for%each.%We%call% this%approach%“learn%once,%write%anywhere.” !!"Tom"Occhino"(React"team"at"Facebook)2

2"h$ps:/

/facebook.github.io/react/blog/2015/03/26/introducing>react>na?ve.html

slide-23
SLIDE 23

Learning(More

  • Official(React(tutorial(from(Facebook
  • Ryan(Florence's(React(training(repo
  • Presenta;on(by(Ember(core(team(member(on(React
  • React=rails(gem
slide-24
SLIDE 24