Skip to content

Commit

Permalink
fix: hoc 타입 에러 수정 #241
Browse files Browse the repository at this point in the history
  • Loading branch information
bottlewook committed Mar 3, 2024
1 parent e451064 commit 7456d1d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/hooks/withRegisterCarWashDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import {
ComponentType, useCallback, useEffect, useState,
} from 'react';
Expand All @@ -9,12 +8,17 @@ import { useRouter } from 'next/navigation';
import { getRequest } from '@remote/api/requests/requests.api';
import { CarWashInfoType } from '@remote/api/types/my-page';

function withRegisterCarWashDetails<Props = Record<string, never>>(
interface WithCarWashInfoProps {
myCarWashInfo: CarWashInfoType;
}

function withRegisterCarWashDetails<Props extends WithCarWashInfoProps>(
WrappedComponent: ComponentType<Props>,
) {
return function RegisteredComponent(props: Props) {
return function RegisteredComponent(props: Omit<Props, keyof WithCarWashInfoProps>) {
const router = useRouter();
const [myCarWashInfo, setMyCarWashInfo] = useState<CarWashInfoType | null>(null);

// eslint-disable-next-line consistent-return
const handleRegister = useCallback(async () => {
try {
Expand All @@ -41,7 +45,7 @@ function withRegisterCarWashDetails<Props = Record<string, never>>(
return null;
}

return <WrappedComponent {...(props as any)} myCarWashInfo={myCarWashInfo} />;
return <WrappedComponent {...props as Props} myCarWashInfo={myCarWashInfo} />;
};
}

Expand Down

0 comments on commit 7456d1d

Please sign in to comment.