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
220
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Data driven rendering
An introduction to ReactJS given at JSOxford
Marc Tamlyn
February 17, 2016
More Decks by Marc Tamlyn
See All by Marc Tamlyn
Arousal and Anxiety
mjtamlyn
1
120
Working with Children
mjtamlyn
1
120
Wallingford Castle Archers Incorporation
mjtamlyn
0
240
Observation and Evaluation
mjtamlyn
0
160
Weird and Wonderful things to do with the ORM
mjtamlyn
3
1.5k
An Introduction to Graphene and Relay
mjtamlyn
6
1.2k
Tech Interviews that don't suck
mjtamlyn
4
1.2k
What's new in Django 1.9
mjtamlyn
1
230
Django Development Milestones
mjtamlyn
1
200
Other Decks in Technology
See All in Technology
AI駆動開発は個人技からチーム戦へ:組織でAIを使いこなすための実践設計
moongift
PRO
0
350
コンポーネント名には何を含めるべきなのか? / what-should-be-included-in-component-names
airrnot1106
0
200
『モンスターストライク』 の運営に伴走する! データ民主化への 解析グループの3つのアプローチ
mixi_engineers
PRO
0
190
AI ネイティブな組織に Gemini Enterprise Agent Platform がなぜ必要なのか
asei
0
110
AI研修(Day2)【MIXI 26新卒技術研修】
mixi_engineers
PRO
2
1.6k
WEBフロントエンド研修【MIXI 26新卒技術研修】
mixi_engineers
PRO
2
830
脱Jenkins、インターン生が挑んだCIツールGitHubActions移行
mixi_engineers
PRO
1
280
システム監視入門
grimoh
5
770
Claude Mythos、Fable...フロンティアAIの最新動向と企業のセキュリティ対策
flatt_security
0
170
Amazon Bedrock Managed Knowledge BaseDive Deep
ren8k
0
280
書籍セキュアAPIについて
riiimparm
0
390
なぜ、あなたのエージェントは言うことを聞かないのか
segavvy
1
590
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Statistics for Hackers
jakevdp
799
230k
New Earth Scene 8
popppiees
3
2.4k
The Spectacular Lies of Maps
axbom
PRO
1
880
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
380
Measuring & Analyzing Core Web Vitals
bluesmoon
9
940
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
230
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
160
Six Lessons from altMBA
skipperchong
29
4.4k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
430
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