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-7/

Memo-Safe Static Hoisting Helper

Wraps React components while hoisting eligible statics from memoized sources without copying memo internals.

Capabilities

Hoists custom statics from memo sources

  • Wrapping a memoized component that defines a custom string static copies that static to the wrapper while leaving an existing wrapper static unchanged. @test

Skips memo internals across React 16.11 and 16.12+

  • When the source is a React.memo component shaped like React 16.11 (object with $$typeof, type, compare), the wrapper retains its own displayName/propTypes/defaultProps/type and does not receive memo internals, yet exposes the source's custom static. @test
  • When the source is a React.memo component shaped like React 16.12+ (memo wrapper whose .type holds the inner component), the wrapper likewise keeps its own render contract and metadata while exposing the source's custom static. @test

Preserves symbol statics on memo sources

  • A symbol-named static on a memoized source is hoisted to the wrapper while memo internals are left untouched and wrapper symbol statics are not overwritten. @test

Implementation

@generates

API

/**
 * Hoists non-React statics from a source component onto a target wrapper while respecting React.memo internals.
 *
 * @param {React.ComponentType} targetComponent - The wrapper component that should receive statics.
 * @param {React.ComponentType} sourceComponent - The component providing statics, possibly a memoized component from React 16.11+.
 * @param {Record<string, boolean>=} excludeStatics - Optional map of statics to skip during hoisting.
 * @returns {React.ComponentType} The target component after hoisting.
 */
function memoSafeHoist(targetComponent, sourceComponent, excludeStatics);

Dependencies { .dependencies }

hoist-non-react-statics { .dependency }

Hoists statics between React components while handling memo and forwardRef internals safely.

Install with Tessl CLI

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

tile.json