CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-hoist-non-react-statics

Copies non-react specific statics from a child component to a parent component

95

1.09x
Overview
Eval results
Files

task.mdevals/scenario-2/

Static Hoisting Wrapper

Create a higher-order component that wraps a React component and mirrors non-React statics to the wrapper while respecting React blacklists and user-specified exclusions.

Capabilities

Mirrors custom statics

  • Given a wrapped component with a string static and a Symbol static, the returned wrapper exposes both statics with their original property descriptors preserved (e.g., getters stay getters). @test

Skips React/intrinsic cases

  • When wrapping an intrinsic component such as "div", the wrapper returns the original target unchanged. @test
  • React-reserved statics like displayName and propTypes on the wrapped component are not copied onto the wrapper. @test

Honors user exclusions

  • When provided an omit map (e.g., { secret: true }), the wrapper skips those statics but still mirrors other custom statics. @test

Prototype-aware hoisting

  • Statics defined on the wrapped component's prototype chain (up to but not including Object.prototype) are mirrored to the wrapper. @test

Implementation

@generates

API

/**
 * Wraps a React component with a HOC that mirrors non-React statics to the wrapper.
 * Reserved React statics stay untouched; user-provided omit map allows skipping keys.
 */
function withStatics(
  WrappedComponent,
  options = { omit: undefined }
) {}

Dependencies { .dependencies }

hoist-non-react-statics { .dependency }

Copies non-React static properties while respecting React static blacklists.

Install with Tessl CLI

npx tessl i tessl/npm-hoist-non-react-statics

tile.json