[에러] Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
config = headers : {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
그러나 내 코드에서는 heard 를 삽입하는 것이 먹히지 않았다.
그러나 해결하고 나서 바로 다음 에러가 발생하였다.
Uncaught (in promise) TypeError: Cannot read property 'protocol' of null
=> 알고보니 detailFetchUrl 쪽에서 초기 랜더링시에 모든 detail 컴포넌트를 fetch 해오면서 생기는 오류 였다.
index.js:1 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.
fetch요청을 여러번 빠르게 하다보니 이런 에러가 나타나는 에러.
블로그를보고 useFetch 안에 있는 useEffect 로 커스텀 훅 안에있는 상태들을 초기화해야한다고 감이오고 그렇게 해놨더니 다시 저 에러가 나타나지 않았다.