You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
主講人: Ohtani
筆記工: Jan
QA
1. 解釋 component 中的三大生命週期運作流程
Mount
流程:
Mount
」的流程Update
所謂的 Update 也就是再次執行渲染的過程,在 React 中唯一能夠觸發畫面重繪的手段只有
setState
流程:
Unmount
當該 React Element 不存在於最新 re-render 後的畫面中,就會進入「Unmount」階段
流程:
2. Function component 有生命週期的 API 嗎?
沒有,useEffect 其實不是真的生命週期
3. 在 class component 中的非同步裡以 this.props 來存取 props 可能會有什麼問題?
雖然 props 本身是
immutable
的,但是 this 不是,所以當 class component re-render 時, React 會將最新版的整包 props 以mutable
的方式直接塞到 this 當中,取代 this.props4. 「function component 會自動捕捉該次 render 時的 props 與 state 資料」是什麼意思?
由於 JS closure 的特性,event handler 函式在建立時會綁定到當次的 props 和 state,因此無論何時觸發,event handler 讀到的 props 和 state 始終不變
額外討論:
Beta Was this translation helpful? Give feedback.
All reactions