Copies non-react specific statics from a child component to a parent component
95
Design a utility to wrap a React component while merging static metadata from another component without disturbing reserved React statics already on the target.
version and a target component without it, after wrapping the target exposes version with the source value. @testdisplayName, 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@generates
/**
* 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 };Copies non-React statics between React components while preserving reserved statics.
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