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
110
1
Share
Refactoring, from AngularJS to React
Alex Tzeng
November 03, 2018
Other Decks in Programming
See All in Programming
見せてもらおうか、 OpenSearchの性能とやらを!
shunta27
1
180
Symfonyの特性(設計思想)を手軽に活かす特性(trait)
ickx
0
130
Java 21/25 Virtual Threads 소개
debop
0
340
へんな働き方
yusukebe
6
2.9k
L’IA au service des devs : Anatomie d'un assistant de Code Review
toham
0
220
煩雑なSkills管理をSoC(関心の分離)により解決する――関心を分離し、プロンプトを部品として育てるためのOSSを作った話 / Solving Complex Skills Management Through SoC (Separation of Concerns)
nrslib
3
780
Redox OS でのネームスペース管理と chroot の実現
isanethen
0
560
SkillがSkillを生む:QA観点出しを自動化した
sontixyou
6
3.2k
「話せることがない」を乗り越える 〜日常業務から登壇テーマをつくる思考法〜
shoheimitani
3
450
おれのAgentic Coding 2026/03
tsukasagr
1
140
Laravel Nightwatchの裏側 - Laravel公式Observabilityツールを支える設計と実装
avosalmon
1
320
アーキテクチャモダナイゼーションとは何か
nwiizo
17
4.6k
Featured
See All Featured
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
520
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
510
The agentic SEO stack - context over prompts
schlessera
0
740
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
290
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
260
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
Into the Great Unknown - MozCon
thekraken
40
2.3k
A better future with KSS
kneath
240
18k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
410
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
The SEO identity crisis: Don't let AI make you average
varn
0
440
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