Copies non-react specific statics from a child component to a parent component
95
Design a helper that wraps a base UI component and returns a new component. The wrapper should copy meaningful static metadata from non-intrinsic components so the wrapper behaves like the original, but it must not attempt any static copying when the base component is provided as an intrinsic string (e.g., "div" or "button").
role = "admin") yields a wrapper that renders the original output and preserves that static on the wrapper so downstream code can read it. @test"button" yields a wrapper that renders the element correctly but leaves the wrapper’s own statics untouched, ensuring no statics from the string source are copied. @test@generates
import React from "react";
/**
* Returns a wrapper component that renders the provided base component while preserving static metadata
* from non-intrinsic bases.
*
* @param {React.ComponentType | string} baseComponent - Component or intrinsic tag to wrap.
* @param {string} [label] - Optional suffix to include in the wrapper display name.
* @returns {React.ComponentType} A wrapper component that mirrors the base component's render output.
*/
export function createDomSafeWrapper(baseComponent, label);Copies non-React static properties between components while respecting React-reserved statics. @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