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

Inherited Static Wrapper

Create a wrapper that exposes static metadata from a wrapped component and its prototype chain while leaving React-reserved statics untouched.

Capabilities

Hoists ancestor statics

  • Wrapping a class component whose parent defines role = "base" and the child defines version = 2 exposes both role and version on the wrapper while leaving the original component unchanged. @test

Preserves wrapper statics

  • When the wrapper already defines tag = "wrapper", wrapping a component whose prototype chain defines tag = "component" keeps tag on the wrapper as "wrapper" and still adds other statics like status = "ready" from the source hierarchy. @test

Copies descriptors and symbols

  • Wrapping a component that inherits a getter static info from its grandparent and a symbol-named static from its parent results in the wrapper returning the getter value and preserving the symbol static value. @test

Implementation

@generates

API

import React from 'react';

/**
 * Wraps a React component while exposing non-React statics (including inherited ones) on the wrapper.
 * @param {React.ComponentType<any>} Component - Component to wrap.
 * @param {object} [options] - Optional configuration such as statics to exclude.
 * @returns {React.ComponentType<any>} A wrapper component that renders the original and carries its statics.
 */
export default function wrapWithStatics(Component, options = {});

Dependencies { .dependencies }

hoist-non-react-statics { .dependency }

Hoists non-React static properties (including inherited) from a source component onto a target wrapper, supporting exclusion lists and React-specific static handling. @satisfied-by

Install with Tessl CLI

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

tile.json