You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
훅에서 아래와 같이 에러 메시지를 반환할 때, 해당 라이브러리를 import하여 훅을 사용할 경우 예상한 에러 메시지가 아닌 ReferenceError: Image is not defined 에러가 발생하는 문제가 있습니다.
if(!validators.isClient()){console.log("server call");thrownewError("localStorage is not available in this environment. Please ensure you are running this code in a browser.");}
확인 방법
Next.js에서 라이브러리를 import하여 useLocalStorage 훅을 사용할 때, 500 에러 코드와 함께 ReferenceError: Image is not defined 에러가 발생합니다.
반면, useLocalStorage 코드를 그대로 복사하여 프로젝트 내에서 직접 사용하면, “localStorage is not available in this environment. Please ensure you are running this code in a browser.” 라는 정확한 에러 메시지가 출력됩니다.
결론
라이브러리에서 반환되는 에러 메시지가 프로젝트 내에서 사용할 때와 다르게 출력되는 문제로 보이며, 원인 및 해결 방법을 확인 중입니다.
또한, #91 이슈에서도 동일한 에러 메시지가 발생하는 것으로 보아 실제로 출력되어야 할 에러 메시지가 제대로 전달되지 않은 것으로 추정됩니다.
The text was updated successfully, but these errors were encountered:
suhyeoonn
changed the title
커스텀 훅에서 throw new Error로 반환한 에러메시지가 Image is not defined로 출력되는 문제
훅에서 throw new Error로 반환한 에러메시지가 Image is not defined로 출력되는 문제
Oct 21, 2024
문제 설명
훅에서 아래와 같이 에러 메시지를 반환할 때, 해당 라이브러리를 import하여 훅을 사용할 경우 예상한 에러 메시지가 아닌 ReferenceError: Image is not defined 에러가 발생하는 문제가 있습니다.
확인 방법
Next.js에서 라이브러리를 import하여 useLocalStorage 훅을 사용할 때, 500 에러 코드와 함께 ReferenceError: Image is not defined 에러가 발생합니다.
반면, useLocalStorage 코드를 그대로 복사하여 프로젝트 내에서 직접 사용하면, “localStorage is not available in this environment. Please ensure you are running this code in a browser.” 라는 정확한 에러 메시지가 출력됩니다.
결론
라이브러리에서 반환되는 에러 메시지가 프로젝트 내에서 사용할 때와 다르게 출력되는 문제로 보이며, 원인 및 해결 방법을 확인 중입니다.
또한, #91 이슈에서도 동일한 에러 메시지가 발생하는 것으로 보아 실제로 출력되어야 할 에러 메시지가 제대로 전달되지 않은 것으로 추정됩니다.
The text was updated successfully, but these errors were encountered: