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
Refactoring, from AngularJS to React
Search
Alex Tzeng
November 03, 2018
Programming
120
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Refactoring, from AngularJS to React
Alex Tzeng
November 03, 2018
Other Decks in Programming
See All in Programming
APNsからLive Activityを開始する話
yumnumm
0
170
すこし踏み込む CancellationToken
htkym
2
1.7k
Workers Cache を知る
syumai
0
350
Jetpack Compose Mechanisms
skydoves
2
730
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
480
CodeRabbitの効果検証と過ごしてみた3ヶ月
armondando
0
230
パスワード再設定メールのURLについて知っておこう
uyuki234
0
140
contenteditable と日本語入力に向き合う
colorful12
0
190
【加筆修正版】Laravel のアプリケーションをどこにデプロイするか #phpcon_ehime
akase244
0
150
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
170
TechTown - Creating Composable Callables in Contemporary C++
rollbear
0
110
golang-bob.pdf
iwatsukayura
0
130
Featured
See All Featured
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
490
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
520
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Ruling the World: When Life Gets Gamed
codingconduct
0
400
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Statistics for Hackers
jakevdp
799
230k
How to Think Like a Performance Engineer
csswizardry
28
2.9k
[SF Ruby Conf 2025] Rails X
palkan
3
1.4k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
Producing Creativity
orderedlist
PRO
348
41k
sira's awesome portfolio website redesign presentation
elsirapls
0
450
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
Transcript
W 重構 從 AngularJS 到 React Alex Tzeng fb.me/alxtz.tw
W About Senior-ish frontend developer Often credited as a good
storyteller ( not what I expected )
Story Time
None
A desktop app that stimulates effects unit
Built on an eletron-like desktop framwork Use AngularJS as UI
framework
2 months after joining New 2.0 project
Main problems Rewrite from a 5-year-old codebase Recompile time >
40s Outdated abstraction Several 3000+ line behemoths Legacy tooling Chaos coding style
Turing point
Our frontend team lead Promoted to be the product owner
Tips on bringing in the concepts of enginneering health into
your team.
Always communicate Transparency is one of the most important values
in Agile Tip A Only if you express the problems, then you can solve them
If you expected the codebase will at least last 1
year Tip B Caring about enginneering health will save your time in the long run
Most managers want good code, even when they are obsessing
about the schedule. Tip C They may defend the schedule and requirements with passion; but that’s their job. It’s your job to defend the code with equal passion.
3 main problems
1. DI & $events aren’t scalable
AngularJS uses a modularization system called Depedency Injection
It actually works fine
The problem is we usually mess it in global
And auto inject with angularJS magic Makes it hard to
find where the depedency come from
For larger projects, nested dependency would have less pain to
maintain
Solution: replace Angular1 module with CommonJS / ES6 import
Before After
Problems with AngularJS $events
Hard to trace / debug when event grows No established
pattern, just broadcast
Replacement for $events Redux
Reasons to use Redux Relatively easy to debug Completely framework-agnostic
( works well when migrating ) Well known enough for newcomers
Great choice when working with multiple frameworks
Components in AngularJS Combo
Angular 1.5 introduces Components Combo Works similar to the Web
Components Standard
Combo
Combo template / render()
Combo template / render() props
Combo template / render() props lifecycles ComDidMount ComShldUpdate
Combo template / render() props lifecycles ComDidMount ComShldUpdate Methods
None
Ok, maybe not.
None
Components + CommonJS = Scalable AngularJS
2. Build tools
Most legacy projects uses Gulp as its task runner
Reasons to move from Gulp to npm + webpack Supports
CommonJS module, url rewrite out of the box Better dev experience with dev-server Easier to audit module size, compile time
Build JavaScript using Gulp
Build JavaScript using Gulp Entry files
Build JavaScript using Gulp Entry files Preprocessor
Build JavaScript using Gulp Entry files Preprocessor Output path
Build JavaScript using Webpack Entry files Preprocessor Output path
3. Migrate to React
Why migrate to React More mature ecosystem Easier to hire
/ get in project Familiar with team member
How to migrate Total rewrite Progressively rewrite Rewrite per page
Total rewrite ( rm -rf ./ ) Too risky for
production project Only apply for core components Hard to estimate time
Progressively rewrite React & AngularJS coexist Value backward compatibility Only
rewrite when code change
Progressively rewrite actually simple
Progressively rewrite Follows web component standards Easy to reuse component
design
Summary (Story) Care more about engineering health Self-aware is the
key to clean code Refactoring using the scrum way
Summary (3 problems) Nested dependency is more scalable Redux for
cross-framework state Gulp -> Webpack Progressively migrate to React