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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
110
Wallingford Castle Archers Incorporation
mjtamlyn
0
230
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
SONiCで構築・運用する生成AI向けパブリッククラウドネットワーク ~実装編~
sonic
0
310
FPGAの開発コンペでZephyrを使ってみた
iotengineer22
0
160
“詰む”前に仕組みを作れ 〜技術の波に溺れないためのキャッチアップ術〜
takasyou
5
2.3k
手塩にかけりゃいいってもんじゃない
ming_ayami
0
620
あなたの知らないPDFのアクセシビリティ
lycorptech_jp
PRO
0
220
自宅LLMの話
jacopen
1
690
10年間のブログ発信を振り返って見えたWebアプリケーションエンジニアとしての軌跡
stefafafan
0
170
MUSUBI 田中裕一『AIと共に行う「しごとのリデザイン」- スモールバックオフィス編』AI Ops Lab #4
musubi
0
280
[AWS Summit Japan 2026]迷っているあなたへ_小さな一歩が、やがて自分を助けてくれる
sh_fk2
1
270
2026年6月23日 Syncable Tech + Start Python Club にて
hamukazu
0
140
攻撃者視点で考えるDetection Engineering
cryptopeg
3
2k
水を運ぶ人としてのリーダーシップ
izumii19
2
400
Featured
See All Featured
The Curse of the Amulet
leimatthew05
1
13k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
230
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
850
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
250
GitHub's CSS Performance
jonrohan
1033
470k
How to train your dragon (web standard)
notwaldorf
97
6.7k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
360
Large-scale JavaScript Application Architecture
addyosmani
515
110k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2k
Accessibility Awareness
sabderemane
1
140
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
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