@wordpress/compose
Version:
WordPress higher-order components (HOCs).
8 lines (7 loc) • 1.33 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/higher-order/with-instance-id/index.tsx"],
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type {\n\tWithInjectedProps,\n\tWithoutInjectedProps,\n} from '../../utils/create-higher-order-component';\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport useInstanceId from '../../hooks/use-instance-id';\n\ntype InstanceIdProps = { instanceId: string | number };\n\n/**\n * A Higher Order Component used to provide a unique instance ID by component.\n */\nconst withInstanceId = createHigherOrderComponent(\n\t< C extends WithInjectedProps< C, InstanceIdProps > >(\n\t\tWrappedComponent: C\n\t) => {\n\t\treturn ( props: WithoutInjectedProps< C, InstanceIdProps > ) => {\n\t\t\tconst instanceId = useInstanceId( WrappedComponent );\n\t\t\t// @ts-ignore\n\t\t\treturn <WrappedComponent { ...props } instanceId={ instanceId } />;\n\t\t};\n\t},\n\t'instanceId'\n);\n\nexport default withInstanceId;\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,2CAA2C;AAC3C,6BAA0B;AAchB;AAPV,IAAM,qBAAiB;AAAA,EACtB,CACC,qBACI;AACJ,WAAO,CAAE,UAAuD;AAC/D,YAAM,iBAAa,uBAAAA,SAAe,gBAAiB;AAEnD,aAAO,4CAAC,oBAAmB,GAAG,OAAQ,YAA0B;AAAA,IACjE;AAAA,EACD;AAAA,EACA;AACD;AAEA,IAAO,2BAAQ;",
"names": ["useInstanceId"]
}