국밥 개발자

  • 홈
  • 태그
  • 방명록

Component 1

[TypeScript] Component Polymorphic하게 사용하기

잘못된 Polymorphic Component 예시 component 타입에 따라 필요한 props가 다름. 모든 props가 선택적(optional)으로 처리되어, 런타임에 필요한 props가 누락될 수 있음 ex) import React, { MouseEventHandler } from "react"; type ButtonType = "button" | "a"; interface ButtonProps { component: ButtonType; href?: string; onclick?: MouseEventHandler; children: React.ReactNode; } const Button = ({ component, href, onclick, children }: ButtonProps) => ..

Typescript 2024.01.27
이전
1
다음
더보기
  • 분류 전체보기 (116)
    • DevOps (21)
    • MSA (27)
    • React (9)
    • Typescript (5)
    • FrontEnd (5)
    • Error (6)
    • NestJS (3)
    • Rust (1)
    • Algorithm (25)
    • AWS (2)
    • Git (10)
    • HTTP (2)
    • 개발 (0)

최근글과 인기글

  • 최근글
  • 인기글
Git Hub

Copyright © Kakao Corp. All rights reserved.

티스토리툴바