본문 바로가기
개발 공부/웹개발

오류 해결 - Warning: Can't perform a React state update on an unmounted component.

by 크롱이크 2021. 7. 19.

이번 ha2 시험에서 다음과 같은 오류들을 만났다. 섹션투를 두번을 들었지만 그때도 지금도 해결하지 못하다가 시험중에 계속된 구글링으로 결국 찾아냈다.

Warning: An update to App inside a test was not wrapped in act(...). When testing, code that causes React state updates should be wrapped into act(...): act(() => { 블라블라블라~~~

 

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.

해당 에러가 발생한 상황은 비동기 작업을 처리하는 과정에서 발생하였다

useEffect의 cleanup function을 이용해 해결할 수 있다.

 

다음의 사이트를 잘 읽어보면 해결할 수 있다.

https://juliangaramendy.dev/blog/use-promise-subscription

 

반응형

댓글