說起 React hooks 應該無人不知無人不曉,在去年轟轟烈烈的出世,是 React 16.8 中增加的新功能。
以往只能在 class 裡寫 states,在能夠使用 hooks 以後, function 裡也可以操作 states 了。傑克,這真是太神奇了!
這讓原本寫 class components 的人紛紛改轉寫 functional components,也更能掌握 components 的渲染時機,減少不必要的渲染次數。究竟這些神奇的 hooks 是怎麼實做出來的?
本講座將帶大家一同推測常使用的 useEffect 以及 useState 的 hooks 實作原理。
2020 JSDC: https://2020.jsdc.tw/
影片連結:https://fb.watch/5IMGkVnfqQ/