I T H

[에러해결] d[("get" + method)] is not a functionTypeError: d[("get" + method)] is not a function 본문

에러 코드 해결

[에러해결] d[("get" + method)] is not a functionTypeError: d[("get" + method)] is not a function

thdev 2024. 2. 13. 18:29
- Calender의 데이터 값을 관리하는 useState 부분에서 다음과 같은 에러가 발생했다.

 

[ 에러 해결 전 코드 ]

 

 

[ 해결 방법 ]

 

- calenderEvent의 start와 end의 타입이 Date로 되어있다.

- 데이터 상태값을 관리하는 useState의 start와 end의 값에 "toDate()"를 넣어주었다.

const [events, setEvents] = useState([
    {
      start: moment().toDate(),
      end: moment().add(1, "hours").toDate(),
      title: "default",
    },
  ] as unknown as CalendarEvent[]);

 

 

[ 에러 해결 후 코드 ]