Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Data driven rendering
Search
Marc Tamlyn
February 17, 2016
Technology
1
160
Data driven rendering
An introduction to ReactJS given at JSOxford
Marc Tamlyn
February 17, 2016
Tweet
Share
More Decks by Marc Tamlyn
See All by Marc Tamlyn
Arousal and Anxiety
mjtamlyn
1
50
Working with Children
mjtamlyn
1
74
Wallingford Castle Archers Incorporation
mjtamlyn
0
180
Observation and Evaluation
mjtamlyn
0
94
Weird and Wonderful things to do with the ORM
mjtamlyn
3
1.3k
An Introduction to Graphene and Relay
mjtamlyn
6
1.2k
Tech Interviews that don't suck
mjtamlyn
4
1.1k
What's new in Django 1.9
mjtamlyn
1
170
Django Development Milestones
mjtamlyn
1
160
Other Decks in Technology
See All in Technology
AWSLambdaMCPServerを使ってツールとMCPサーバを分離する
tkikuchi
1
2.1k
SREの視点で考えるSIEM活用術 〜AWS環境でのセキュリティ強化〜
coconala_engineer
1
250
AI AgentOps LT大会(2025/04/16) Algomatic伊藤発表資料
kosukeito
0
120
Zabbixチョットデキルとは!?
kujiraitakahiro
0
180
「家族アルバム みてね」を支えるS3ライフサイクル戦略
fanglang
4
650
Webアプリを Lambdaで動かすまでに考えること / How to implement monolithic Lambda Web Application
_kensh
7
1.2k
ゆるくVPC Latticeについてまとめてみたら、意外と奥深い件
masakiokuda
2
230
食べログが挑む!飲食店ネット予約システムで自動テスト無双して手動テストゼロを実現する戦略
hagevvashi
1
160
Vision Pro X Text to 3D Model ~How Swift and Generative Al Unlock a New Era of Spatial Computing~
igaryo0506
0
260
Classmethod AI Talks(CATs) #21 司会進行スライド(2025.04.17) / classmethod-ai-talks-aka-cats_moderator-slides_vol21_2025-04-17
shinyaa31
0
420
Startups On Rails 2025 @ Tropical on Rails
irinanazarova
0
250
Creating Awesome Change in SmartNews
martin_lover
1
230
Featured
See All Featured
Become a Pro
speakerdeck
PRO
27
5.3k
Done Done
chrislema
183
16k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.8k
Practical Orchestrator
shlominoach
186
10k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
135
33k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
21k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2k
Embracing the Ebb and Flow
colly
85
4.6k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.6k
How STYLIGHT went responsive
nonsquared
99
5.5k
Transcript
Data driven rendering An introduction to ReactJS Marc Tamlyn Photo
by Konstans Zafeiri on photocrowd.com
None
This is not •Babel •Webpack •Browserify •Flux •Redux •Relay
Motivation
None
Motivation •Responsive to input changes •Interactivity •Rendering only •Not a
jQuery mess!
What is React? •View layer of a traditional MVC •Virtual
DOM •Single directional data flow
What is a Component? •Takes input (props) •Returns an element
•Class with a render() method
What is a Component? var Photo = React.createClass({ render: function()
{ return React.createElement('img', { src: this.props.imageSrc, }); } });
Components with children var Photos = React.createClass({ render: function() {
var photos = this.props.photos.map((photo) => { return React.createElement(Photo, { imageSrc: photo.imageSrc, }); }); return React.createElement('div', {}, photos); } });
JSX •Preprocessor for React.createElement() •Compile using your JS preprocessor of
choice
JSX var Photos = React.createClass({ render: function() { var photos
= this.props.photos.map((photo) => { return <Photo imageSrc={photo.imageSrc} /> }); return <div>{photos}</div>; } });
Virtual DOM •Renders in memory-light virtual DOM •Compares changes between
trees •Flushes only changes to the document •Debounces rendering
Data flow •Components have state as well as props •Minimise
use of state •Handle at top level and pass functions around •Handle externally altogether!
Data flow var Photos = React.createClass({ getInitialState: function() { return
{photos: this.props.photos}; }, onLove: function() { … }, render: function() { var photos = this.state.photos.map((photo) => { return <Photo imageSrc={photo.imageSrc} onLove={this.onLove} /> }); return <div>{photos}</div>; } });
Data flow var Photo = React.createClass({ render: function() { return
<div> <img src={this.props.imageSrc} /> <a onclick={this.props.onLove}>Love</a> </div>; } });
Data flow •YOUR CHOICE •External communication
Example time!
$.fn.reactify <div data-react-component="Photos" data-react-props="{{ photos_json }}"></div> <script> $(document).reactify(); </script>
Work with us photocrowd.com/jobs
Thank you github.com/mjtamlyn twitter.com/mjtamlyn photocrowd.com/mjtamlyn