hoist-react-statics
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

NPM

The problem

How many times you wrap one component by another? Use the React's HOC paradigm?

const MySuperComponentWrapper = props => (
   <AmazingStuff><WrappedComponent {...props} /></AmazingStuff>
)

That about propTypes? types?

The Solution

import hoistReactStatics from 'hoist-react-staticsr';
 
const MySuperComponentWrapper = hoistReactStatics(props => (
  <AmazingStuff><WrappedComponent {...props} /></AmazingStuff>
), WrappedComponent);

But why?

Are you mad mate? I need only one line to solve this problem! I have written

const MySuperComponentWrapper = props => (
   <AmazingStuff><WrappedComponent {...props} /></AmazingStuff>
)
MySuperComponentWrapper.propTypes = WrappedComponent.propTypes;

But

  • what about Flow/TS types?
    Huh?

Licence

MIT

Package Sidebar

Install

npm i hoist-react-statics

Weekly Downloads

1,735

Version

1.0.2

License

MIT

Unpacked Size

78.5 kB

Total Files

8

Last publish

Collaborators

  • kashey