Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
README.md
index.d.ts
index.js
index.spec.tsx
package.json
tsconfig.json

README.md

@react-comfy/props

A set of props typings in TypeScript.

Installation

yarn add -D @react-comfy/props
# or
npm i --save-dev @react-comfy/props

Usage

Import typings and use them as props. You can combine props by using intersection types.

// Example usage of ControlledInputProps and StyleableProps
import * as React from 'react'
import { ControlledInputProps, StyleableProps } from '@react-comfy/props'

interface MyComponentProps {
  foo: 'bar'
}

export const MyComponent: React.FC<
  MyComponentProps & StyleableProps & ControlledInputProps
> = ({ foo, disabled, value, className, style, onChange, ...rest }) => {
  const change = React.useCallback<React.ChangeEventHandler<HTMLInputElement>>(
    ev => {
      if (onChange) {
        onChange(ev, ev.currentTarget.value)
      }
    },
    [onChange]
  )

  return (
    <div className={className} style={style} {...rest}>
      <input disabled={disabled} value={value} onChange={change} />
    </div>
  )
}
You can’t perform that action at this time.