WordPress.org

@wordpress/compose Edit

The compose package is a collection of handy Higher Order Components (HOCs) you can use to wrap your WordPress components and provide some basic features like: state, instance id, pure…

Installation Installation

Install the module

npm install @wordpress/compose --save

This package assumes that your code will run in an ES2015+ environment. If you’re using an environment that has limited or no support for ES2015+ such as lower versions of IE then using core-js or @babel/polyfill will add support for these methods. Learn more about it in Babel docs.

Top ↑

Usage Usage

import { withInstanceId } from '@wordpress/compose';

function WrappedComponent( props ) {
    return props.instanceId;
}

const ComponentWithInstanceIdProp = withInstanceId( WrappedComponent );

Refer to each Higher Order Component’s README file for more details.

Code is Poetry.

Skip to toolbar