Copies non-react specific statics from a child component to a parent component
95
Create a wrapper that exposes static metadata from a wrapped component and its prototype chain while leaving React-reserved statics untouched.
role = "base" and the child defines version = 2 exposes both role and version on the wrapper while leaving the original component unchanged. @testtag = "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. @testinfo 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@generates
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 = {});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-staticsdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10