$30 off During Our Annual Pro Sale. View Details »
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
180
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
77
Working with Children
mjtamlyn
1
88
Wallingford Castle Archers Incorporation
mjtamlyn
0
200
Observation and Evaluation
mjtamlyn
0
120
Weird and Wonderful things to do with the ORM
mjtamlyn
3
1.4k
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
210
Django Development Milestones
mjtamlyn
1
180
Other Decks in Technology
See All in Technology
type-challenges を全問解いたのでエッセンスと推し問題を紹介してみる
kworkdev
PRO
0
160
Dify on AWS の選択肢
ysekiy
0
120
Android Studio Otter の最新 Gemini 機能 / Latest Gemini features in Android Studio Otter
yanzm
0
540
履歴テーブル、今回はこう作りました 〜 Delegated Types編 〜 / How We Built Our History Table This Time — With Delegated Types
moznion
14
8.8k
.NET 10 のパフォーマンス改善
nenonaninu
2
3.9k
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
3
21k
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
970
シンプルを極める。アンチパターンなDB設計の本質
facilo_inc
0
560
今すぐGoogle Antigravityを触りましょう
rfdnxbro
0
250
ページの可視領域を算出する方法について整理する
yamatai1212
0
140
MCP・A2A概要 〜Google Cloudで構築するなら〜
shukob
0
110
経営から紐解くデータマネジメント
pacocat
9
1.8k
Featured
See All Featured
A designer walks into a library…
pauljervisheath
210
24k
Fireside Chat
paigeccino
41
3.7k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Visualization
eitanlees
150
16k
A Tale of Four Properties
chriscoyier
162
23k
Docker and Python
trallard
46
3.7k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
Thoughts on Productivity
jonyablonski
73
4.9k
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