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

ForwardRef Static Wrapper

Create a wrapper helper for React.forwardRef components that preserves custom statics while avoiding forward-ref internals.

Capabilities

Hoists custom statics from forwardRef sources

  • Wrapping a forwardRef source exposes its custom string and symbol statics (for example, version and a Symbol-keyed meta object) on the returned wrapper. @test

Skips forwardRef internals

  • The wrapper keeps its own displayName and defaultProps after hoisting and does not surface the source component's $$typeof or render properties. @test

Preserves ref and render behavior

  • The wrapper forwards refs to the original forwardRef implementation and invokes the provided onRender callback exactly once per render while passing through props. @test

Implementation

@generates

API

import React from "react";

/**
 * Wraps a React.forwardRef component with an optional render logger,
 * while preserving custom statics without copying forward-ref internals.
 *
 * @param {React.ForwardRefExoticComponent<any>} component forwardRef component to wrap
 * @param {(props: object) => void} onRender optional callback invoked on render
 * @returns {React.ForwardRefExoticComponent<any>} wrapped forwardRef component
 */
export function withForwardRefStatics(component, onRender);

Dependencies { .dependencies }

react { .dependency }

Provides creation of forwardRef wrappers and elements.

hoist-non-react-statics { .dependency }

Hoists non-React statics from a source component onto a wrapper while respecting forwardRef internals.

Install with Tessl CLI

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

tile.json