1.0.0 • Published 2 years ago

get-react-props v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Get-react-props

TS utility types to extract component props

Install

npm install get-react-props

Usage

import { GetProp, GetProps } from 'get-react-props';

const Foo: FC<{ foo: 'bar' }> = ({ foo }) => {
  return <div>{foo}</div>;
};

const Bar: FC<{ fooProps: GetProps<typeof Foo> }> = ({ fooProps }) => {
  return (
    <div>
      <Bar {...fooProps} />
    </div>
  );
};

const Baz: FC<{ foo: GetProp<typeof Foo, 'foo'> }> = ({ foo }) => {
  return (
    <div>
      <Foo foo={foo} />
    </div>
  );
};