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
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
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
210
Prismを使った型安全な暗号化_関数型まつり2026
_fhhmm
0
170
Claude Opus 4.6以後の受託開発エンジニアの変化(Claude Code開発ノウハウ大公開スペシャルbyクラスメソッド)
iidatakuma
1
970
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
290
仕様駆動開発の消費期限
watany
8
4.1k
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
200
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
0
120
AIが無かった頃の素敵な出会いの話
codmoninc
1
380
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
450
5分で問診!Composer セキュリティ健康診断
codmoninc
0
860
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
490
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
1
670
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
225
10k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
400
GraphQLとの向き合い方2022年版
quramy
50
15k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
450
How to build a perfect <img>
jonoalderson
1
5.8k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
430
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Making the Leap to Tech Lead
cromwellryan
135
10k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Building Adaptive Systems
keathley
44
3.2k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
45k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.2k
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