- 리액트 18에서는 useEffect가 초기 렌더 시 두번 실행 된다
- 이벤트 구독하는게 있다면 클린업에서 꼭 해치워 줘야한다
- The right question isn’t “how to run an effect once,” but “how to fix my effect so that it works after remounting”.
- The cleanup function should stop or undo whatever the effect was doing. The rule of thumb is that the user shouldn’t be able to distinguish between the effect running once (as in production) and an effect → cleanup → effect sequence (as you’d see in development).
- useEffect는 이름이 이상하다 useSyncronize가 더 적합하다
참고
https://m.youtube.com/watch?v=HPoC-k7Rxwo
https://mobile.twitter.com/dan_abramov/status/1534594885998854144?s=21&fbclid=IwAR3ydNBLPzM6VGVbiSWgnJqpC7wE6HgDWk19_m5o9detOWcnDrbHO3PMx-g