회고/Today I Learn
Warning: Cannot update a component (`*`) while rendering a different component (`*`). To locate the bad setState() call inside `*`, follow the stack trace as described in
김첨지
2023. 9. 20. 17:18
Warning: Cannot update a component (`Router`) while rendering a different component (`SearchContainer`). To locate the bad setState() call inside `SearchContainer`, follow the stack trace as described in
https://reactjs.org/link/setstate-in-render
아래와 같이 되어있는 코드를
router.replace(pathname + "?" + queryString);
useEffect를 사용하여 해결하였다.
useEffect(() => {
router.replace(pathname + "?" + queryString);
}, []);