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
React.lazyとSuspenseで行うLazy Load
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
camcam_lemon
May 27, 2019
Programming
560
2
Share
React.lazyとSuspenseで行うLazy Load
React.js meetup #7 (LT会)での登壇資料です
camcam_lemon
May 27, 2019
More Decks by camcam_lemon
See All by camcam_lemon
オレを実装してデザイン実装楽したい
lemon
0
79
要素のサイズを変えずに押しやすくする
lemon
0
91
iOSのキーボード入力ビューをカスタマイズする
lemon
0
310
視え方と文字の大きさ
lemon
1
450
Yarn WorkSpaces × React Nativeの環境構築
lemon
0
320
フロントエンドにおけるアーキテクチャとの向き合い方
lemon
10
5k
UI/UXデザイナーがデザインしてるもの
lemon
2
340
react-reduxで追加されたHooks APIの良い所と使い方
lemon
5
1k
ESLintで始めるTypeScriptの静的解析
lemon
8
2.2k
Other Decks in Programming
See All in Programming
運転動画を検索可能にする〜Cosmos-Embed1とDatabricks Vector Searchで〜/cosmos-embed1-databricks-vector-search
studio_graph
1
630
Structured Concurrency, Scoped Values and Joiners in the JDK 25 26 27
josepaumard
1
140
JAWS-UG横浜 #100 祝・第100回スペシャルAWS は VPC レスの時代へ
maroon1st
0
210
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
970
20年以上続くプロダクトでも使い続けられる静的解析ツールを求めて
matsuo_atsushi
0
120
アクセシビリティ試験の"その後"を仕組み化する
yuuumiravy
1
190
🦞OpenClaw works with AWS
licux
1
320
PHPでバイナリをパースして理解するASN.1
muno92
PRO
0
390
WebAssembly を読み込むベストプラクティス 2026年春版 / Best Practices for Loading WebAssembly (Spring 2026)
petamoriken
5
1k
Firefoxにコントリビューションして得られた学び
ken7253
2
150
Running Swift without an OS
kishikawakatsumi
0
870
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
360
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
220
Deep Space Network (abreviated)
tonyrice
0
130
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
190
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
SEO for Brand Visibility & Recognition
aleyda
0
4.5k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
160
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
900
Scaling GitHub
holman
464
140k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
530
Into the Great Unknown - MozCon
thekraken
41
2.4k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
180
Transcript
React.lazyとSuspenseで行う Lazy Load React.js meetup #7
None
React.lazyとSuspenseって? React 16.6から追加された非同期処理やLazy Load をサポートする機能 Suspense - ・・・dynamic importが完了するまで違う要素 を表示するコンポーネント
React.lazy - ・・・コンポーネントをdynamic importするAPI @loadable/component を使おう SSRには未対応 ただし... なので注意
従来のLazy Load
React.lazyとSusepense を使ってLazy Loadをする
React.lazyとSusepenseを使う
React.lazyとSusepenseを使う コンポーネントの外側で React.lazyでdynamic importする
React.lazyとSusepenseを使う fallback・・・ロード中に表示する要素 children・・・dynamic importする要素
めちゃくちゃ簡潔に書けるぞ!
もっと動的にdynamic import してみよう
やりたいこと 2 React.lazyとSuspenseを使うのは1回 3 ついでにbundleもわけよう 1 propsからimportする要素を決める
None
マウント時に1回だけReact.lazyでコンポーネント を取得するように処理を行う
undefinedにすると無限ループしてしまう depsには空配列を指定(必要であればprops)
webpackChunkNameに [request] を指定すると typeに対応するファイルを別にバンドルする
Formがnullの時があるので三項演算子で判定してから Suspenseを返すようにしている
まとめ 1 custom hooksによる責務の分離 2 可読性の向上 Hooksでより良い体験を propsによる動的かつ汎用的な操作 React.lazyとSuspenseの体験よき
ご静聴ありがとうございました!