본문 바로가기

에러2

[React] Cannot update a component (`MyProvider`) while rendering a different component (`App`) 리액트로 작업 중 아래와 같은 에러가 발생했다. 내용인즉 한 컴포넌트가 렌더링 되는 도중에 다른 컴포넌트의 상태를 변경하면 발생하는 에러였다.Warning: Cannot update a component (`MyProvider`) while rendering a different component (`App`). To locate the bad setState() call inside `App`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render Error Component Stack 내가 발생했던 에러는 부모로부터 전달받은 Props를 컨텍스트 API에 바로 저장하려고 하여서 발생하였다. 즉, 렌더링 도중.. 2025. 3. 16.
jest 절대 경로 찾지 못하는 문제 💭 상황사이드 프로젝트에서 테스트 코드를 작성하기 위해 Jest를 도입하였다. 현재 프로젝트에서는 폴더 구조의 뎁스가 깊어 상대구조로 파일을 찾는 것은 너무 복잡하여 절대 경로를 사용하게 되었다. 절대 경로를 도입한 이후부터 Jest에서 정상적으로 모듈을 찾지 못하는 문제가 발생하였다.   🥧 에러 내용Cannot find module '@/core/models/components/properties/Property' from 'src/tests/core/models/components/properties/Property.spec.ts'  🕵️‍♂️ 에러 파악인터넷 검색 결과 동일한 문제를 겪은 사람들이 많은지 블로그에 해결방법이 여럿나왔다. 대표적인 방법으로 jest의 환경설정에서 moduleN.. 2024. 12. 29.