compose-children
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

Compose Children

Compose for react components:

import composeChildren from "compose-children";

type ComposedComponentProps = Component1Props &
  Component2Props &
  Component3Props;

const ComposedComponent = composeChildren<ComposedComponentProps>(
  Component1,
  Component2,
  Component3,
);

The above is equivalent to:

type ComposedComponentProps = Component1Props &
  Component2Props &
  Component3Props;

const ComposedComponent = ({ children, ...props }: ComposedComponentProps) => (
  <Component1 {...props}>
    <Component2 {...props}>
      <Component3 {...props}>{children}</Component3>
    </Component2>
  </Component1>
);

Readme

Keywords

none

Package Sidebar

Install

npm i compose-children

Weekly Downloads

0

Version

0.0.4

License

ISC

Unpacked Size

2.98 kB

Total Files

4

Last publish

Collaborators

  • manvalls.com