1.0.0 • Published 6 years ago

with-hocs v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

with-hocs

function Sample(props) {
  return <h1>HELLO {props.capitalized}!</h1>;
}

// pass high-order components via hocs props
const Enhance = withHOCs({ importAs: 'hocs' })(Sample);

...

const hocs = [
  defaultProps({
    name: 'World',
  }),

  withPropsOnChange(['name'], ({ name }) => ({
    capitalized: name.toUpperCase(),
  })),
];

// <Enhance hocs={hocs} name="sydney" /> → HELLO SYDNEY!