4. 리액트
madrid> (djr-nn) useSelector, useEffect 조합 과정에서 에러발생
패스트코드블로그
2021. 11. 3. 20:28
https://stackoverflow.com/questions/64718224/useeffect-loop-due-to-useselector-updating
useEffect loop due to useSelector updating
I have a useEffect function Component () { const facets = useSelector(getFacets) useEffect(() => { dispatch(search(facets, param2, param3)) }, [dispatch, facets, param2, par...
stackoverflow.com
Sooooo Redux has a few store methods; dispatch being one of them. For me, the store method I was looking for was getState. More info if you look here and cmd/ctrl + F 'getState'
I didn't think I could access the state within my slice because React would not allow me to use useSelector within the slice for obvious reasons. What was not obvious to me at the time was that I could gain access with getState