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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
camcam_lemon
May 27, 2019
Programming
570
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
82
要素のサイズを変えずに押しやすくする
lemon
0
93
iOSのキーボード入力ビューをカスタマイズする
lemon
0
310
視え方と文字の大きさ
lemon
1
460
Yarn WorkSpaces × React Nativeの環境構築
lemon
0
330
フロントエンドにおけるアーキテクチャとの向き合い方
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
過去のレビュー知見をSkillsで資産化した話
pkshadeck
PRO
1
2.1k
2026年のソフトウェア開発を考える(2026/05版) / Software Engineering Scrum Fest Niigata 2026 Edition
twada
PRO
24
13k
Modding RubyKaigi for Myself
yui_knk
0
340
Agentic UI beyond Chats Architecture Patterns & Open Standards @ngMunich 05/2026
manfredsteyer
PRO
0
110
TypeSpec で繋ぐ複数プロダクトの型安全
maroon8021
1
140
AlarmKitで明後日起きれるアラームアプリを作る
trickart
0
140
権限チェックの一貫性を型で守る TypeScript による多層防御
mnch
3
230
AWSはOSSをどのように 考えているのか?
akihisaikeda
0
130
Sans tests, vos agents ne sont pas fiables
nabondance
0
140
【ディップ|26年新卒研修資料】TDD実装演習
dip_tech
PRO
0
280
【ディップ|26年新卒研修資料】OpenAPI/Swagger REST API研修
dip_tech
PRO
0
260
ローカルLLMでどこまでコードが書けるか / How much code can be written on a local LLM
kishida
2
380
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
510
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
240
A Tale of Four Properties
chriscoyier
163
24k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
390
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.5k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1.4k
Automating Front-end Workflow
addyosmani
1370
210k
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の体験よき
ご静聴ありがとうございました!