Expectation Violation: Duplicate atom key "~".

꾸준히·2025년 2월 11일

TroubleShooting

목록 보기
2/6

------- < Error > -------
Expectation Violation: Duplicate atom key "~".

This is a FATAL ERROR in production. But it is safe to ignore this warning if it occurred because of hot module replacement.

Next.js에서 recoil을 사용할 때 발생하는 에러이다.
기능적으로는 문제는 없지만 console에 에러가 찍혀 이 문제를 해결하려고 한다.

난수 생성하여 해결하기

  1. 라이브러리 설치 ( npm i uuid )
  2. state 키에 난수 추가하기
export const yearFilterAtom = atom({
  key: `yearFilter${v1}`,
  default: { idx: 0, filter: `${getFullYear}년` },
});

0개의 댓글