useMemo
- ๊ฐ์ ์ฌํ์ฉํ๊ธฐ ์ํด ๋ฉ๋ชจ๋ฆฌ์ ๊ฐ์ ์บ์ฑํ๋ Hook
const value = useMemo(()=>{
return ์บ์ฑํด์ ๊ธฐ์ตํ๊ณ ์์ ๊ฐ
},[dependency])
useReducer
state๊ฐ ๋ฐ๋ ๋๋ง๋ค ํ๋ฉด์ ๋ ๋๋ง ํด์ค
- Reducer : state ๋ฅผ ๋ณ๊ฒฝํ๋ ํจ์
- Dispatch : reducer์๊ฒ state๋ฅผ ๋ณ๊ฒฝํด๋ฌ๋ผ๋ ์๊ตฌ dispatch๋ฅผ ํธ์ถํ๋ฉด reducer๊ฐ ํธ์ถ๋
- Action : Dispatch ์ ๋ด์ฉ
useReducer ์ฌ์ฉ
const [state, dispatch] = useReducer(reducer, ์ํ์ ์ด๊ธฐ๊ฐ);
reducer ์ฌ์ฉ
const reducer = (state, action) => {
//๋ณดํต if ๋ switch ์ฌ์ฉ
}
dispatch ์ฌ์ฉ (action ์ ๋ณดํต ๊ฐ์ฒดํํ๋ก)
dispatch({type: '', payload:})
๋ฐ์ํ
'๐ TIL' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[220807]nwitter (0) | 2022.08.07 |
---|---|
[220804] React Redux (0) | 2022.08.04 |
[220729] ๋ฆฌ์กํธ ์ค๊ฐ (0) | 2022.07.29 |
[220728] (0) | 2022.07.29 |
[220726] React (0) | 2022.07.27 |