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

React Static Preservation Wrapper

Design a utility to wrap a React component while merging static metadata from another component without disturbing reserved React statics already on the target.

Capabilities

Hoists custom statics

  • Given a source component with a custom static version and a target component without it, after wrapping the target exposes version with the source value. @test

Preserves target React statics

  • When the target defines displayName, defaultProps, and propTypes and the source defines different values for the same keys, wrapping leaves the target's values unchanged while still adding other source statics. @test

Returns original target

  • The wrapper returns the same target component reference to support fluent composition. @test

Implementation

@generates

API

/**
 * Wraps a target React component with static metadata from a source component while leaving existing React-reserved statics on the target untouched.
 *
 * @param {React.ComponentType|Function} targetComponent - The component to receive statics.
 * @param {React.ComponentType|Function} sourceComponent - The component providing statics.
 * @returns {React.ComponentType|Function} The original target component.
 */
function wrapComponent(targetComponent, sourceComponent);
export { wrapComponent };

Dependencies { .dependencies }

hoist-non-react-statics { .dependency }

Copies non-React statics between React components while preserving reserved statics.

Install with Tessl CLI

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

tile.json