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
Hello World 2018 - We need to talk about Preact
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Hello World Tech Conference
February 15, 2018
Programming
87
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Hello World 2018 - We need to talk about Preact
Hello World Tech Conference
February 15, 2018
More Decks by Hello World Tech Conference
See All by Hello World Tech Conference
Hello World 2018 - Learn how to get that dream job at Google!
helloworldconf
0
120
Hello World 2018 - Introduction to Swift
helloworldconf
0
68
Hello World 2018 - Understanding attacker behaviors, motivations and common ways of operation
helloworldconf
0
77
Hello World 2018 - GraphQL A query language for your API
helloworldconf
1
89
Hello World 2018 - Why Ruby?
helloworldconf
0
50
Hello World 2018 - Recent Advances in Machine Learning
helloworldconf
0
73
Hello World 2018 - Quality from the start
helloworldconf
0
38
Hello World 2017 - React Native
helloworldconf
0
120
Hello World 2017 - Testing & QA - Carreira Profissional?
helloworldconf
0
86
Other Decks in Programming
See All in Programming
アルゴリズムは何を圧縮しているのか ─ Haskell から育った「圧縮代数」というメンタルモデル
naoya
16
3.6k
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
180
Prismを使った型安全な暗号化_関数型まつり2026
_fhhmm
0
150
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
450
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
1
190
FDEが実現するAI駆動経営の現在地
gonta
2
220
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
1.7k
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
370
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
3
1k
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
170
AIエージェントで 変わるAndroid開発環境
takahirom
2
720
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
200
Featured
See All Featured
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
660
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
420
Designing Powerful Visuals for Engaging Learning
tmiket
1
460
A Modern Web Designer's Workflow
chriscoyier
698
190k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
740
Code Review Best Practice
trishagee
74
20k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
180
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
630
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.7k
Transcript
WE NEED TO TALK ABOUT PREACT
HELLO! I am Sara I work at YLD and make
useless stuff on the internet @NikkitaFTW
Portugal
REMEMBER THIS JOKE?
Y’ALL JUST LOST TO A TEAM OF FLAMINGOS
PREACT
I know what your first question is !
I brought them stickers
1. What ? 2. Who ? 3. Why ? 4.
Future ? 5. The CLI
WHAT IS PREACT ?
None
IS IT PRODUCTION READY ?
None
YES !
WHO MADE PREACT ?
Jason Miller / @developit
WHY PREACT ?
THE COMMUNITY There is an amazing community behind preact !
None
None
None
None
None
IT’S PERFORMANT Preact is 3KB and was made with performance
in mind
X KB OF JS IS NOT THE SAME AS X
KB OF IMAGES The browser has to download it but also parse it and in older devices this may be the biggest problem
BENCHMARKS
Firefox 57.0 (64-bit)
Chrome Version 62 (64-bit)
REACT COMPATIBILITY You can use it with any react component
yarn add preact-compat { // ... resolve: { alias: {
'react': 'preact-compat', 'react-dom': 'preact-compat', // Not necessary unless you consume a module using `createClass` 'create-react-class': 'preact-compat/lib/create-react-class' } } // ... } How ?
What’s included in Preact ?
ES6 CLASS COMPONENTS And all the awesome lifecycle methods of
course
HIGH ORDER COMPONENTS Create them composes
FUNCTIONAL COMPONENTS Functions that just receive props as arguments and
return JSX/VDOM
CONTEXT In some cases, you want to pass data through
the component tree without having to pass the props down manually at every level. You can do this directly in with the “context” API.
REFS We all use it, don’t lie
VIRTUAL DOM DIFFING Preact's diff is simple but effective, and
extremely fast.
What’s added in Preact ?
PROPS AND STATE IN RENDER this.props and this.state are passed
to render() for you. THIS IS SO SWEET
class Home extends Component { constructor() { super(); this.state =
{ loading: true } } render = () => { const { name } = this.props; const { loading } = this.state; return ( <div> {loading ? ‘Loading...’ : name} </div> ) } }
class Home extends Component { state = { loading: true
} render = ({ name }, { loading }) => ( <div> {loading ? ‘Loading...’ : name} </div> ) }
DOM UPDATES Batching of DOM updates, debounced/collated using setTimeout (can
also use requestAnimationFrame)
CSS CLASS You can just use class for CSS classes.
className is still supported, but class is preferred.
Component and element recycling / pooling.
What’s missing in Preact ?
DANGEROUSLY SET innerHTML Do we really want this ? There
is preact-markup to fill this gap
SYNTHETIC EVENTS Preact's browser support target does not require this
extra overhead. Preact uses the browser's native addEventListener for event handling
BROWSER SUPPORT Preact supports modern browsers (Chrome, Firefox, Safari, Edge)
and IE9+
FUTURE
FASTER DIFFING ALGORITHM
ARRAY RETURNS
FRAGMENT SUPPORT
ASYNC DIFFING
DEMO TIME Let’s talk about the preact-cli
THANK YOU