SlideShare a Scribd company logo
前端爆肝之旅
+
React 上山前的小專案心得分享
鍾曜年 Jay Chung
github.com/xJkit
切勿小看前端
別像當初的我...
相關技術研討
● 開發工具:
○ Webpack
○ Babel
○ Chrome DevTool, debugger, Tamper
Data, Postman
○
● 程式語言:
○ JavaScript
■ ES6
■ Promise
○ Functional Programming
■ map, reduce, filter
■ pure functions, avoid side effects
■ immutability, persistent data
structure
● React
■ react, react-dom
■ react-router
● Future Work
○ Unit Test (Karma)
○ Redux, ImmutableJS
○ User Authentication / Database
自介
鍾曜年
成大不成材研究生 (不玩底層的 EE)
“傳統”前端工程師( 曾以為 HTML, CSS/SASS, jQuery 可以打天下)
畢業時期漸漸接觸後端 (node.js, express.js, mongoDB, AWS EC2)
傳統的前端工程師
HTML/CSS
jQuery
80%
20%
以為靠 CSS + jQuery 可打遍天下
(咦?居然還不用懂 JavaScript…)
Modern 的前端工程師
JavaScript
HTML/
CSS
80%
20%
大量的 JS 框架...
多虧了 node.js
不是 CSS 變少,
是JS 變多了。
而且是爆炸性成長
感謝 node.js 讓 JavaScript 變成 Full Stack language
傳統的前端工程師
index.html
Modern 的前端工程師
index.html
就這樣?
傳統的前端工程師
server side
rendering
每一頁都是
後端 render
好的 HTML
Modern 的前端工程師
client side
rendering
只有第一頁是
後端 render
的結果
Single
Page
Application
與 React 的第一次
與 React 的第一次...慘敗收場
WTF is npm?
原來只有 HTML/CSS 遠遠不夠
1. Webpack
2. Babel
3. JavaScript
a. Promise
b. ES6
4. Functional Programming
a. map, reduce, filter
b. pure functions, avoid side effects
c. immutability, persistent data structure
5. React
a. react, react-dom
b. react-router
6. Redux
7. Unit Test
Prerequisites...
崩
潰
1. Webpack
2. Babel
3. JavaScript
a. Promise
b. ES6
4. Functional Programming
a. map, reduce, filter
b. pure functions, avoid side effects
c. immutability, persistent data structure
5. React
a. react, react-dom
b. react-router
6. Redux
7. Unit Test
Prerequisites...
Webpack
Webpack webpack.config.js
app.js
app.scss
Webpack
打包完成
就這樣? Yes.
當然還需要其他的套件幫忙...thank you npm
package.json
1. Webpack
2. Babel
3. JavaScript
a. Promise
b. ES6
4. Functional Programming
a. map, reduce, filter
b. pure functions, avoid side effects
c. immutability, persistent data structure
5. React
a. react, react-dom
b. react-router
6. Redux
7. Unit Test
Prerequisites...
Babel (Transpiler)
Babel (Transpiler)
ES6
ES5
有了 Babel
就趕快體驗用 ES6 來開發網頁吧
1. Webpack
2. Babel
3. JavaScript
a. ES6
b. Promise
4. Functional Programming
a. map, reduce, filter
b. pure functions, avoid side effects
c. immutability, persistent data structure
5. React
a. react, react-dom
b. react-router
6. Redux
7. Unit Test
Prerequisites...
JavaScript ES6 (ES2015, ECMAScript)
● Variable Scope
a. var → let, const
b. functional scope → functional & block-level scope
● Template String (Interpolation)
JavaScript ES6 (ES2015, ECMAScript)
● Arrow Function
○ 皆為 Anonymous function
○ Shorter Syntax
○ “this” 綁定的改變
(ES5: Global → ES6:定義時所在物件)
JavaScript ES6 (ES2015, ECMAScript)
● Default parameters
● Rest parameters, Spread parameters (...)
● Destructuring ( let {a, b} = myObject )
● Class
JavaScript Promise
callback 痛點:pyramid of doom
JavaScript Promise
把 callback 平面化
1. Webpack
2. Babel
3. JavaScript
a. Promise
b. ES6
4. Functional Programming
a. map, reduce, filter
b. pure functions, avoid side effects
c. immutability, persistent data structure
5. React
a. react, react-dom
b. react-router
6. Redux
7. Unit Test
Prerequisites...
Functional Programming
Functional Programming
1. Easy to test.
2. Easy to read & reason about
3. Avoid confusion, errors in code
大專案常遇到: Spaghetti Code
Have to run code
“Imperatively…?”
What is FP?
1. Do everything with functions
Non-functional way v.s Functional way
必須搞清楚資料的流動會經過哪些函數
1. 而不是不同的物件
(not properties, methods, this...)
2. 而不是 Imperative way
像是菜單一條一條列出來並且該做
些什麼
2. Use Pure Functions
Use Pure Functions
1. Avoid Side Effects
a. 不要把 console.log() 加到函數裡面
2. Iuput ---> () ---> Output
3. 僅在乎 I/O, 不做多餘的事
3. Do Not Iterate
Do Not Iterate
1. 別用 for-loop, while-loop
2. 改用 map, reduce, filter
4. Avoid Mutability
A non-functional joke
5. Persistent Data Structure
Persistent Data Structure
解決痛點:
無腦式的 Immutable 單純靠 Copy & Paste 會變慢 + 記憶體耗盡
Persistent Data Structure: Link List
更換資料結構
Persistent Data Structure: Tree
更換資料結構
Functional Programming Language
Haskell /Elm
ClojureScript
Scala
Lisp
Om
Functional Programming Libraries for JavaScript
Mori
Immutable.js
underscore.js
lodash
Ramda
來聽美女大師講解 Functional Programming
Anjana Vakil: Learning Functional Programming with JavaScript - JSUnconf 2016
非常淺顯易懂!
1. Webpack
2. Babel
3. JavaScript
a. Promise
b. ES6
4. Functional Programming
a. map, reduce, filter
b. pure functions, avoid side effects
c. immutability, persistent data structure
5. React
a. react, react-dom
b. react-router
6. Redux
7. Unit Test
Prerequisites...
小專案+踩雷心路路程
React Weather App
React Router Example
React YouTubeDataAPI Search App
React Video Search and Playlist
https://github.com/xJkit
Video Search and Playlist “MOCK”
影片搜尋
播放清單
中文歌
英文歌
韓文歌
搜尋
搜尋首頁
Video Search and Playlist (播放清單:搜尋結果)
周杰倫影片搜尋
播放清單
中文歌
英文歌
韓文歌
搜尋
周杰倫Jay Chou X aMEI【不該
Shouldn't Be】Official MV
周杰倫X aMEI 【不該Shouldn't Be】
今年華語樂壇最震撼的對唱深情
詮釋雪地裡的愛情唯美而哀傷 ....
周杰倫Jay Chou X aMEI【不該
Shouldn't Be】Official MV
周杰倫X aMEI 【不該Shouldn't Be】
今年華語樂壇最震撼的對唱深情
詮釋雪地裡的愛情唯美而哀傷 ....
Video Search and Playlist (播放清單:中文歌)
影片搜尋
播放清單
中文歌
英文歌
韓文歌
搜尋
周杰倫Jay Chou X aMEI【不該 Shouldn't Be】Official MV
周杰倫X aMEI 【不該Shouldn't Be】 今年華語樂壇最
震撼的對唱深情詮釋雪地裡的愛情唯美而哀傷 ....
周杰倫Jay Chou X aMEI【不該 Shouldn't Be】Official MV
周杰倫X aMEI 【不該Shouldn't Be】 今年華語樂壇最
震撼的對唱深情詮釋雪地裡的愛情唯美而哀傷 ....
周杰倫Jay Chou X aMEI【不該 Shouldn't Be】Official MV
周杰倫X aMEI 【不該Shouldn't Be】 今年華語樂壇最
震撼的對唱深情詮釋雪地裡的愛情唯美而哀傷 ....
Decomposition 將所有物件 Component 化
影片搜尋
播放清單
中文男歌手
中文女歌手
英文歌
韓文歌
搜尋
搜尋首頁
Main
Logo
PlayList
PlayListLink
SearchBar
Display
Decomposition:搜尋結果
dd
影片搜尋
播放清單
中文歌
英文歌
韓文歌
搜尋
Main
Logo
PlayList
PlayListLink
SearchBar
Display
周杰倫Jay Chou X aMEI【不該
Shouldn't Be】Official MV
周杰倫X aMEI 【不該Shouldn't Be】
今年華語樂壇最震撼的對唱深情
詮釋雪地裡的愛情唯美而哀傷 ....
周杰倫Jay Chou X aMEI【不該
Shouldn't Be】Official MV
周杰倫X aMEI 【不該Shouldn't Be】
今年華語樂壇最震撼的對唱深情
詮釋雪地裡的愛情唯美而哀傷 ....
DisplayList
DisplayListDetail
Nav
+新增
Component
組件架構
弄懂資料流向
Debug Tool
Chrome DevTools
debugger;
webpack sourcemap
Tamper data
Postman
Demo
git@github.com:xJkit/react-video-playlist-searcher.git
如果你能過忍受...
投入這麼多時間竟然只在前置作業,而且
還沒碰到 React 的一根汗毛
...還無法阻擋你學習 React 的決心的話
恭喜你拿到 React 的門票
React 學習資源
ReactJS 台灣討論區
React Officials
Thanks for your listening!
git@github.com/xJkit
Future work
Unit Test framework (Mocha, Chai, Karma,...)
每寫完一個 Component 就要寫測試
保持良好習慣
Redux 好用的 React Component 狀態管理器
下一站 React 深造之路: Redux
學習 Redux 大概是 React 重學所花的時間...
但是不學好 Redux 是不能成就大事的!

More Related Content

PDF
React js入門教學
PPT
Exception Handling
PPTX
Java Beans
PPTX
Angular Lifecycle Hooks
PPTX
Java Hello World Program
PDF
WSA : Web Application Development Courses
PDF
ES2015 (ES6) Overview
PDF
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
React js入門教學
Exception Handling
Java Beans
Angular Lifecycle Hooks
Java Hello World Program
WSA : Web Application Development Courses
ES2015 (ES6) Overview
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...

What's hot (20)

PDF
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
PDF
Html5 Interview Questions & Answers
PDF
Arrays in Java
PDF
Hands-On Java web passando por Servlets, JSP, JSTL, JDBC, Hibernate, DAO, MV...
PDF
Creating your own exception
PDF
Angular Pipes Workshop
PDF
Introduction to thymeleaf
PDF
ES6 presentation
PPT
Core java concepts
PPTX
Scala fundamentals
PPTX
iOS Development, with Swift and XCode
PDF
Zend Certification PHP 5 Sample Questions
PPTX
Whitebox testing of Spring Boot applications
PDF
Core java complete notes - Contact at +91-814-614-5674
PDF
Javapolymorphism
PPTX
Get Started with ReactJS 18 Development Services_ New Features and Updates.pptx
ODP
Java Persistence API
PPT
Introduction To C#
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
Html5 Interview Questions & Answers
Arrays in Java
Hands-On Java web passando por Servlets, JSP, JSTL, JDBC, Hibernate, DAO, MV...
Creating your own exception
Angular Pipes Workshop
Introduction to thymeleaf
ES6 presentation
Core java concepts
Scala fundamentals
iOS Development, with Swift and XCode
Zend Certification PHP 5 Sample Questions
Whitebox testing of Spring Boot applications
Core java complete notes - Contact at +91-814-614-5674
Javapolymorphism
Get Started with ReactJS 18 Development Services_ New Features and Updates.pptx
Java Persistence API
Introduction To C#
Ad

Similar to 前端爆肝之旅+React上山前的小專案心得分享 (20)

PDF
程式人雜誌 -- 2015 年1月號
PDF
2016 前端潮玩意兒
PDF
JS and NG - ntut iLab 2015/07/14
PDF
NodeJS基礎教學&簡介
PPTX
180518 ntut js and node
PDF
React.js what do you really mean?
PDF
Legacy code 讀書會 1st (Ch1 - Ch5)
PPT
Underscore
PDF
Noder eyes for frontend guys
PDF
如何在有限資源下實現十年的後端服務演進
PDF
Node.js從無到有 基本課程
PDF
前端工程開發實務訓練
PPT
Node.js在淘宝的应用实践
PDF
前端技術大亂鬥
PDF
Node.js 入門 - 前端工程開發實務訓練
PDF
JavaScript 快速複習 2017Q1
PDF
Javascript
KEY
D2_Node在淘宝的应用实践
PPTX
深入淺出Node.JS
PDF
JavaScript 快速跳坑指南
程式人雜誌 -- 2015 年1月號
2016 前端潮玩意兒
JS and NG - ntut iLab 2015/07/14
NodeJS基礎教學&簡介
180518 ntut js and node
React.js what do you really mean?
Legacy code 讀書會 1st (Ch1 - Ch5)
Underscore
Noder eyes for frontend guys
如何在有限資源下實現十年的後端服務演進
Node.js從無到有 基本課程
前端工程開發實務訓練
Node.js在淘宝的应用实践
前端技術大亂鬥
Node.js 入門 - 前端工程開發實務訓練
JavaScript 快速複習 2017Q1
Javascript
D2_Node在淘宝的应用实践
深入淺出Node.JS
JavaScript 快速跳坑指南
Ad

More from Yao Nien Chung (6)

PDF
Use React Patterns to Build Large Scalable App
PDF
Enhance react app with patterns - part 1: higher order component
PDF
Lets make a better react form
PDF
Rollup v.s Webpack: shallow compare the next generation ES6 bundlers
PDF
Javascript 攻佔桌面應用程式:使用 electron
PDF
軟體測試是在測試什麼?
Use React Patterns to Build Large Scalable App
Enhance react app with patterns - part 1: higher order component
Lets make a better react form
Rollup v.s Webpack: shallow compare the next generation ES6 bundlers
Javascript 攻佔桌面應用程式:使用 electron
軟體測試是在測試什麼?

前端爆肝之旅+React上山前的小專案心得分享