/with-default-props

a HOC that applies default props to React component

Primary LanguageTypeScriptMIT LicenseMIT

@citrus327/with-default-props

Download Version

a HOC that applies default props to React component

Installation

pnpm install @citrus327/with-default-props

Usage

import { withDefaultProps } from '@citrus327/with-default-props'

interface SimpleProps {
  word?: string
}

export const Simple: React.FC<SimpleProps> = (props) => {
  return <h1>Hello{props.word}</h1>
}


const Wrapped = withDefaultProps(Simple, {
  word: " world",
})