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
2
550
React.lazyとSuspenseで行うLazy Load
React.js meetup #7 (LT会)での登壇資料です
camcam_lemon
May 27, 2019
Tweet
Share
More Decks by camcam_lemon
See All by camcam_lemon
オレを実装してデザイン実装楽したい
lemon
0
66
要素のサイズを変えずに押しやすくする
lemon
0
82
iOSのキーボード入力ビューをカスタマイズする
lemon
0
280
視え方と文字の大きさ
lemon
1
430
Yarn WorkSpaces × React Nativeの環境構築
lemon
0
320
フロントエンドにおけるアーキテクチャとの向き合い方
lemon
10
5k
UI/UXデザイナーがデザインしてるもの
lemon
2
330
react-reduxで追加されたHooks APIの良い所と使い方
lemon
5
1k
ESLintで始めるTypeScriptの静的解析
lemon
8
2.1k
Other Decks in Programming
See All in Programming
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
440
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
400
CSC307 Lecture 06
javiergs
PRO
0
680
ThorVG Viewer In VS Code
nors
0
760
AIエージェントの設計で注意するべきポイント6選
har1101
7
3.4k
Vibe codingでおすすめの言語と開発手法
uyuki234
0
220
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
980
AgentCoreとHuman in the Loop
har1101
5
220
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
4
2.7k
CSC307 Lecture 02
javiergs
PRO
1
770
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2.1k
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
130
Featured
See All Featured
Ethics towards AI in product and experience design
skipperchong
2
190
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
190
Ruling the World: When Life Gets Gamed
codingconduct
0
140
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
430
What's in a price? How to price your products and services
michaelherold
247
13k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
52
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.2k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
820
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の体験よき
ご静聴ありがとうございました!