Front J

  • 홈

typescript generic type mapping 1

Generic Property를 통한 콜백함수 인자의 타입 매핑하기

진행 중인 프로젝트 내 비슷한 로직을 처리하는 Modal UI가 10개가량 존재하는 것을 발견했다. 자연스럽게 컴포넌트로 추출되었을 법 한데 무엇 때문인지 각각 존재하고 있었다. // 초기 컴포넌트의 형태 type Payload = { foo: string; bar: string; baz: string; }; type WithRequestComponentProps = {}; const WithRequestComponent = ({}: WithRequestComponentProps) => { const { register, handleSubmit } = useForm(); const onSubmit: SubmitHandler = (payload) => { // 서버로의 요청 }; return ( ); };..

개발/기타 2022.06.12
프로필사진

어제보다 분명하게 성장할 수 있도록 꾸준히, 인지가 아닌 기억하기 위해 기록하자.

  • 분류 전체보기 (41)
    • 개발 (41)
      • Javascript (10)
      • type-challenges (8)
      • 기타 (23)

최근글과 인기글

  • 최근글
  • 인기글

Copyright © Kakao Corp. All rights reserved.

티스토리툴바