如何做webgis網(wǎng)站優(yōu)化關(guān)鍵詞是什么意思
React 16.8 版本 類組件?和 函數(shù)組件 兩種組件共存,到目前 React 18 版本,官方已經(jīng)不在推薦使用類組件,在函數(shù)組件中 hooks 是必不可少的,它允許我們函數(shù)組件像類組件一樣可以使用組件的狀態(tài),并模擬組件的生命周期等一系列行為。
????????本文為 react_hooks 的匯總,希望對正在學(xué)習(xí)react-hooks的你,能夠有所幫助!
一、核心hooks
我們知道在類組件中 react 具有三大屬性,分別為 state、props 、ref,在 hooks 中同樣存在相應(yīng)的 hooks
1、useState
useState
https://blog.csdn.net/weixin_61791370/article/details/139679655
2、useRef
useRef
https://blog.csdn.net/weixin_61791370/article/details/139679773
3、forwardRef
forwardRef
https://blog.csdn.net/weixin_61791370/article/details/139679851
4、uselmperativeHandle
useImperativeHandlehttps://blog.csdn.net/weixin_61791370/article/details/139679920
二、模擬生命周期 hooks
?
1、useEffect
useEffect
https://blog.csdn.net/weixin_61791370/article/details/139679969
2、useLayoutEffect
useLayoutEffecthttps://blog.csdn.net/weixin_61791370/article/details/139680028
三、組件通信 hooks
1、useReducer
useReducer
https://blog.csdn.net/weixin_61791370/article/details/139995775
2、useContext
useContexthttps://blog.csdn.net/weixin_61791370/article/details/139995886