React children

    0

    0

    Giovanny Gongora

    Codiga's TypeScript Recipes

    Define a button with ReactNode type for children

    interface IButtonProps {
      reference?: React.RefObject<HTMLButtonElement>
      children?: React.ReactNode
    }
    const button = (props: IButtonProps) => {
      return (
        <button ref={props.reference}>{props.children}</button>
    	)
    }
    <Button reference={props.reference}>
      {props.children}
    </Button>
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.