Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Reactjs @ MOSUT x Tainan.py
Search
Yuanhsiang Cheng
August 25, 2014
Technology
370
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Reactjs @ MOSUT x Tainan.py
Yuanhsiang Cheng
August 25, 2014
Transcript
35 slides
Reactjs yhsiang @ MOSUTxTainan.py 8/23 Sat.
Who am I?
〳腋僽㔔捀し➮㣖랔✫
HWꅾ䏞♳涗罏 将虋䊨玑䌌
React
MVC but V
templates but components
update DOM reconciliation
Features
Virtual DOM also render on server-side
Data Flow one-way reactive data
JSX XML-like syntax
var HelloMessage = React.createClass({ render: function({ return <div>Hello {this.props.name}</div>; });
}); React.renderComponent( <HelloMessage name="John" />, mountNode);
var HelloMessage = React.createClass({ render: function({ return ! }); });
React.renderComponent( , mountNode); React.DOM.div(null, “Hello “, this.props.name); HelloMessage({name: “John”})
React+LiveScript
{div} = React.DOM HelloMessage = React.createClass do render: -> div
{}, “Hello #{@props.name}” React.renderComponent ( HelloMessage name: ‘John’), mountNode
A stateful component
{div} = React.DOM Timer = React.createClass do getInitialState: -> secondsElapsed:
0 tick: -> @setState secondsElapsed: @state.secondsElapsed + 1 componentDidMount: -> @interval = setInterval @tick, 1000 componentWillUnmount: -> clearInterval @interval render: -> div {}, “Seconds Elapsed: #{@state.secondsElapsed}” React.renderComponent Timer!, mountNode
props vs state external v.s. internal
Lifecyle
componentWillMount() componentDidMount() componentWillReceiveProps() Mounting Updating this.getDOMnode(), setTimeout, xhr shouldComponentUpdate() componentWillUpdate()
componentDidUpdate() Unmounting componentWillUnmount()
{div} = React.DOM Timer = React.createClass do getInitialState: -> secondsElapsed:
0 tick: -> @setState secondsElapsed: @state.secondsElapsed + 1 componentDidMount: -> @interval = setInterval @tick, 1000 componentWillUnmount: -> clearInterval @interval render: -> div {}, “Seconds Elapsed: #{@state.secondsElapsed}” React.renderComponent Timer!, mountNode
React-boostrap
More? propTypes, mixins, statics
Flux application architecture
unidirectional data flow
Action Controller Model View Model Model Model Model View View
View View
Action Dispatcher Store View Action
https://github.com/facebook/flux
callbacks waitFor
Action Dispatcher action = type: ‘NEW_THREAD’ to: ‘hychen’ text: ‘嗨懂’
threadID: ‘78123’ messageID: ‘1234’ Message Store Thread Store Message View Thread View ‘78123’: participants: <[ hychen ly ]> messageList: <[ 1234 ]>
Action Dispatcher action = type: ‘NEW_THREAD’ to: ‘hychen’ text: ‘嗨懂’
threadID: ‘78123’ messageID: ‘1234’ Message Store Thread Store Message View Thread View ‘1234’: text: ‘嗨懂’ thread: ‘78123’ author: ‘ly’
flux, fluxxor, fluxy
reactjs.tw on Facebook @lyforever
CC-BY 4.0
More Decks by Yuanhsiang Cheng
See All by Yuanhsiang Cheng
How to rebuild a websocket service by golang and redis
yhsiang
0
1.2k
From React to React Native Web
yhsiang
0
250
Rethink React in Elm
yhsiang
0
1.1k
開源與工程師的自我修養
yhsiang
0
240
Sayit in Taiwan
yhsiang
0
270
LY sayit
yhsiang
0
220
Webpack pack your web
yhsiang
17
12k
2015 Summer of ?
yhsiang
0
350
How to be a good wan-jun
yhsiang
1
240
Other Decks in Technology
See All in Technology
Re:ゼロから始めるシェアハウスのペットな鯖
silmin_
0
260
実測データからサービスの成長余力を測る。負荷シナリオ・テストデータ・限界値の設計
kazatohiei
0
140
信頼性を犠牲にせず、PR マージからデプロイまで人の介入を完全にゼロにするまでの道のり
knwoop
4
2k
エンタープライズIAMについて - ID・権限をどう統制するか
oidfj
1
290
IoTのデータ保存をSREの観点で考える
grimoh
1
120
マネジメントされる側の仕事は「文句」を言うこと
riyaamemiya
7
6k
変更差分を読むために環境を整備しよう
pipepasta
1
610
Test Impact Analysis を武器に立ち向かう、AI 時代のテスト増加に対するヌーラボのアプローチ / getting-started-datadog-test-impact-analysis
k6s4i53rx
2
310
「個社」ではなく「業界」の課題を解く AI 対話開発 ー 価値を広げる設計と、価値を守るエンジニアリング ー
ivry_presentationmaterials
4
830
Terraform 0 to 100:100個以上のリポジトリを常に最新にし続けるための自動化
sue445
3
1.3k
みん強Lightning! データ基盤ひとりでできるかな
endonanana
0
170
OCI Artifact による自動運転タクシーに向けた OTA 基盤の構築
biwashi
1
250
Featured
See All Featured
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
850
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
850
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
60k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Bash Introduction
62gerente
615
220k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
880
Amusing Abliteration
ianozsvald
1
400
Game over? The fight for quality and originality in the time of robots
wayneb77
1
340
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
570
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
500