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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Hello World Tech Conference
February 15, 2018
Programming
84
1
Share
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
67
Hello World 2018 - Understanding attacker behaviors, motivations and common ways of operation
helloworldconf
0
76
Hello World 2018 - GraphQL A query language for your API
helloworldconf
1
87
Hello World 2018 - Why Ruby?
helloworldconf
0
50
Hello World 2018 - Recent Advances in Machine Learning
helloworldconf
0
71
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
85
Other Decks in Programming
See All in Programming
CSC307 Lecture 17
javiergs
PRO
0
310
サーバーレスで作る、動画データ管理基盤
oyasumipants
0
340
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
3.3k
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
300
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
11k
TypeSpec で繋ぐ複数プロダクトの型安全
maroon8021
1
320
OCRを使ってゲームのアイテムをデータ化する
kishikawakatsumi
0
130
TAKTでAI駆動開発の品質を設計する
j5ik2o
4
240
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
1.8k
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
6
1.3k
RTSPクライアントを自作してみた話
simotin13
0
420
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
4
430
Featured
See All Featured
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
170
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
250
Balancing Empowerment & Direction
lara
6
1.1k
WENDY [Excerpt]
tessaabrams
11
38k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
530
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
280
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Documentation Writing (for coders)
carmenintech
77
5.4k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
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