When you apply a HOC to a component, though, the original component is wrapped with a container component. That means the new component does not have any of the static methods of the original component.

// Define a static method
WrappedComponent.staticMethod = function() {/*...*/}
// Now apply a HOC
const EnhancedComponent = enhance(WrappedComponent);

// The enhanced component has no static method
typeof EnhancedComponent.staticMethod === 'undefined' // true
However, this requires you to know exactly which methods need to be copied. You can use hoist-non-react-statics to automatically copy all non-React static methods:

import hoistNonReactStatic from 'hoist-non-react-statics';
function enhance(WrappedComponent) {
  class Enhance extends React.Component {/*...*/}
  hoistNonReactStatic(Enhance, WrappedComponent);
  return Enhance;
Another possible solution is to export the static method separately from the component itself.

// Instead of...
MyComponent.someFunction = someFunction;
export default MyComponent;

// ...export the method separately...
export { someFunction };

// ...and in the consuming module, import both
import MyComponent, { someFunction } from './MyComponent.js';
To solve this, you could copy the methods onto the container before returning it:

function enhance(WrappedComponent) {
  class Enhance extends React.Component {/*...*/}
  // Must know exactly which method(s) to copy :(
  Enhance.staticMethod = WrappedComponent.staticMethod;
  return Enhance;


React Higher-Order Components Caveats Don’t Use HOCs Inside the render Method

React Higher-Order Components Convention: Wrap the Display Name for Easy Debugging

React Higher-Order Components Convention: Maximizing Composability

React Higher-Order Components Convention: Pass Unrelated Props Through to the Wrapped Component

React Higher-Order Components Don’t Mutate the Original Component. Use Composition.

React Higher-Order Components Use HOCs For Cross-Cutting Concerns

React Higher-Order Components

React Portals Event Bubbling Through Portals

React Portals Usage

React Portals

React Introducing JSX JSX Represents Objects

React Introducing JSX JSX Prevents Injection Attacks

React Introducing JSX Specifying Children with JSX

React Introducing JSX Specifying Attributes with JSX

React Introducing JSX JSX is an Expression Too

React Introducing JSX Embedding Expressions in JSX

React Introducing JSX

React State and Lifecycle The Data Flows Down

React State and Lifecycle Using State Correctly State Updates are Merged

React State and Lifecycle Using State Correctly State Updates May Be Asynchronous

React State and Lifecycle Using State Correctly Do Not Modify State Directly

React State and Lifecycle Adding Lifecycle Methods to a Class

React State and Lifecycle Adding Local State to a Class

React State and Lifecycle Converting a Function to a Class

React State and Lifecycle

React Test Renderer Ideas

React Test Renderer Reference testInstance.children

React Test Renderer Reference testInstance.parent

React Test Renderer Reference testInstance.props

React Test Renderer Reference testInstance.type

React Test Renderer Reference testInstance.instance

React Test Renderer Reference testInstance.findAllByProps()

React Test Renderer Reference testInstance.findAllByType()

React Test Renderer Reference testInstance.findAll()

React Test Renderer Reference testInstance.findByProps()

React Test Renderer Reference testInstance.findByType()

React Test Renderer Reference testInstance.find()

React Test Renderer Reference testRenderer.root

React Test Renderer Reference testRenderer.getInstance()

React Test Renderer Reference testRenderer.unmount()

React Test Renderer Reference testRenderer.update()

React Test Renderer Reference testRenderer.toTree()

React Test Renderer Reference TestRenderer.act()

React Test Renderer Reference TestRenderer.create()

React Test Renderer Overview

React Test Renderer

React DOM Elements All Supported HTML Attributes

React DOM Elements Differences In Attributes style

React DOM Elements Differences In Attributes dangerouslySetInnerHTML

PyTorch Tracking ResultTracker Fsspec

PyTorch Tracking ResultTracker Base

PyTorch Tracking Overview & Usage

PyTorch HPO Ax (Adaptive Experimentation)

PyTorch HPO Overview & Usage Quickstart Example

PyTorch Local