Copying Over Static Methods

You should copy over any static methods in the HOC.


RESETRUNFULL
WrappedComponent.staticMethod = function() {/*...*/}const EnhancedComponent = enhance(WrappedComponent);function enhance(WrappedComponent) {
   class Enhance extends React.Component {/*...*/}
   Enhance.staticMethod = WrappedComponent.staticMethod;
   return Enhance;}

You can use the package 'hoistNonReactStatic' to automatically copy over the static methods without having to know which methods to copy.


RESETRUNFULL
import hoistNonReactStatic from 'hoist-non-react-statics';function enhance(WrappedComponent) {
   class Enhance extends React.Component {/*...*/}
   hoistNonReactStatic(Enhance, WrappedComponent);
   return Enhance;}