server에서 chatUnreadCound
라는 변수를 long
type으로 준다고 명시했다. 수가 너무 크다보니 int보다는 long을 사용한다던데 그럼 React는 이걸 어떻게 받아야 할까?
답은 Bigint
다!
export interface RoomListType {
roomId: number;
roomName: string;
petName: string;
petLv: number;
petPoint: number;
petImageObjKey: string;
friendFirstName: string;
friendLastName: string;
friendProfileImageObjKey: string;
lastUpdatedTime: string;
chatUnreadCount: bigint;
}
이렇게 타입은 bigint
로 받고, 쓸 때는 toString()
으로 바꿔서 사용해야 한다.
toString()
을 사용하지 않으면 아래와 같은 에러가 발생한다.
No overload matches this call.
Overload 1 of 2, '(props: TextProps | Readonly<TextProps>): Text', gave the following error.
Type 'bigint' is not assignable to type 'ReactNode'.
Overload 2 of 2, '(props: TextProps, context: any): Text', gave the following error.
Type 'bigint' is not assignable to type 'ReactNode'.
따라서 아래와 같이 작성하면 해결!