Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
React.js 消えるライフサイクルメソッドについて
Search
takf
October 10, 2019
Programming
170
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
React.js 消えるライフサイクルメソッドについて
takf
October 10, 2019
More Decks by takf
See All by takf
Go未経験・MVC脳のエンジニアが オニオンアーキテクチャを学ぶまで
takfjp
0
48
見やすい PRを作るために取り組んでいること
takfjp
0
70
Denoに入門していきなりAleph.jsを触ってみた
takfjp
0
550
Atomic Design とテストの○○な話
takfjp
2
2k
Node.jsのアップグレードで気をつけたこと
takfjp
1
3k
FARM スタックに触れてみる
takfjp
0
1.7k
React Testing Library の Query について整理してみた
takfjp
0
570
Laravel 初めての業務で遭遇したハマりポイント×2
takfjp
2
3.2k
React で Stateless Functional Component の書き方を盛大に間違えていた話
takfjp
0
470
Other Decks in Programming
See All in Programming
JRuby: Past, Present, and Future
headius
0
220
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
420
Verilogで学ぶCPU自作入門.pdf
uyuki234
7
3.9k
Are APIs Still Relevant in the AI Era?
soyuka
0
390
Webの地図
yosuke_furukawa
PRO
6
5k
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
460
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
320
FreeBSDでZabbixを動かす
kenkino
0
340
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
290
Embedded Swiftで作る自作USBデバイス によるiOSデバイスの自動テスト / iOSDC Japan 2026 glassfiber
glassfiber
0
250
App Intentsのビルドプロセスを支える技術
kntkymt
0
490
iOSDCのペンライトを自動制御したい!
akkeylab
0
330
Featured
See All Featured
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
700
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
550
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Automating Front-end Workflow
addyosmani
1369
210k
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Visualization
eitanlees
153
17k
How STYLIGHT went responsive
nonsquared
100
6.3k
ラッコキーワード サービス紹介資料
rakko
1
5.1M
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
310
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
290
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
380
Transcript
React.js 消えるライフサイクルメソッドについて Misoca 秋のLT大会 2019.10.10
登壇者について furuichi (@takfjp) 株式会社カオナビ所属 主にフロントエンド(React)の開発に携わっています
https://corp.kaonavi.jp/recruit/
Reactのバージョンアップでこれから消えるライフサイクル メソッドについてお話しします ・現在のReactのバージョン v16.10.0 Released! (2019/10現在) ・v17 の登場はまだ未定
これまでの主な Breaking Changes v16.3 (2018/03) - New Context API, 新しいライフサイクルメソッド追加
- getDerivedStateFromProps - getSnapshotBeforeUpdate v16.8 (2019/02) - React Hooks が追加! - -> 関数コンポーネントが State を持てるように
目覚ましい進歩と その裏で消えゆく者たち・・・
componentWillMount componentWillRecieveProps componentWillUpdate 消える(予定)ライフサイクルメソッド
componentWillMount -> UNSAFE_componentWillMount componentWillRecieveProps -> UNSAFE_componentWillRecieveProps componentWillUpdate -> UNSAFE_componentWillUpdate v16.9
より接頭辞 UNSAFE_ がないと warning v17 で完全に削除 (後方互換性なし) -> 接頭辞つきであればであればv17でも動作 ??
componentWillUnmount 消えずに残る者 まだまだ現役じゃぞい
- v17 より非同期レンダリングを正式にサポート - React Fiber (コアエンジン)が差分の整合性を保つため - componentWillHoge が何度も呼ばれる
(render() が何度も実 行されてしまう) ことで DOM の整合性が危うくなる なぜ消える?
- 今後も残るライフサイクルメソッドに置き換え - componentWillRecieveProps -> componentDidUpdate など - getDerivedStateFromProps も置き換え策
- 公式曰く「まれなライフサイクルメソッド」らしい … - ライフサイクルメソッドに依存しない実装 - componentWillMount 内の処理をconstructorに移すなど 対策 (1)
リファクタのコストが高い場合: ❯ npx react-codemod rename-unsafe-lifecycles <path> https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles 対策 (2)
コマンドラインからファイルを指定 -> 廃止予定のメソッド名を自動的に UNSAFE_xxx に置換
Thank you!