Slide 1

Slide 1 text

如何⽤ React 發⼤財 WebComponent 202308 - milkmidi

Slide 2

Slide 2 text

milkmidi (奶綠茶) 
 PositiveGrid Staff Frontend Engineer 
 
 
 [email protected] 
 https: / / www.facebook.com/milkmidifans

Slide 3

Slide 3 text

Ten years ago!

Slide 4

Slide 4 text

jQuery Flash Action Script Silverlight RWD 是三⼩! bootstrap

Slide 5

Slide 5 text

10 年前奶綠出過兩本書 已絕版 每年都要拿 Flash 出來鞭⼀下

Slide 6

Slide 6 text

Web Development Trends in 2023 React / Vue / Angular Flash Action graphQL TailwindCSS webassembly Webpack / Vite No jQuery Test

Slide 7

Slide 7 text

我也想靠 Flash 吃⼀輩⼦呀 結果 Jobs ⼀句話我就失業了

Slide 8

Slide 8 text

Why WebComponent?

Slide 9

Slide 9 text

PM 要請你修改 sign-in 功能,這時你會 ?

Slide 10

Slide 10 text

jQuery 再戰⼗年

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

WebComponent 是你的救贖

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

1 好找,好改 2 限縮 JS scope 3 準時下班

Slide 18

Slide 18 text

PM說: 現在要修改登出鈕按的⾏為。 不急,⼗分鐘後再給我就好

Slide 19

Slide 19 text

這時你要回答?

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

要使⽤前有個 But ⼈⽣就是這個 But

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

How to use?

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

connectedCallback() Invoked when the custom element is first connected to the document's DOM. disconnectedCallback() Invoked when the custom element is disconnected from the document's DOM. attributeChangedCallback() 
 Invoked when one of the custom element's attributes is added, removed, or changed. Life cycle callbacks

Slide 27

Slide 27 text

attributeChangedCallback

Slide 28

Slide 28 text

Shadow DOM 與世隔絕的安全⼩屋 這我家的貓,很可愛吧

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

外層和 Shadow DOM 的 style 不會互相影響 但,也是缺點 透過 attachShadow( { mode } ); 可以讓外層的 JS 是否可以呼叫 shadowDOM 裡的元素 mode: open:element.shadowRoot // ShadowRoot obj mode: closed: element.shadowRoot // null

Slide 31

Slide 31 text

Shadow DOM + slot 這我家的貓,很可愛吧

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

下段語法寫錯,正確為 document.createElement(‘my-component’)

Slide 34

Slide 34 text

Web Component 就是這麼簡單

Slide 35

Slide 35 text

加薪技能樹

Slide 36

Slide 36 text

WebComponent + petite-vue

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

都是尤⼤⼤開發的 Only ~ 6kb DOM-based, mutates in place(not virtual DOM) petite-vue

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

https://www.positivegrid.com/products/spark 實際應⽤

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

WebComponent 限縮 scope petite-vue 處理阿雜的 DOM 事件 本來專案就走 SSR 的情況下,很適合導入

Slide 44

Slide 44 text

工具沒有好或壞 用的好帶你上天堂 還是我家的貓,還是很可愛

Slide 45

Slide 45 text

學習不需要為公司、長官或同事, 
 不需要為別人,只為你自己。 五倍紅寶石-高見龍

Slide 46

Slide 46 text

⼯商服務 Positivegrid 徵 Senior Android Engineer Senior Backend Engineer Machine Learning Engineer C++ Developer

Slide 47

Slide 47 text

QA

Slide 48

Slide 48 text

https://www.facebook.com/cmoneyengineer/photos https://www.facebook.com/groups/2616981278627207 圖片出處