The WordPress block API for Gutenberg has a withInstanceId
package.
They say,
Some components need to generate a unique id for each instance. This could serve as suffixes to element ID's for example. Wrapping a component with withInstanceId provides a unique instanceId to serve this purpose.
and show an example:
/**
* WordPress dependencies
*/
import { withInstanceId } from '@wordpress/compose';
function MyCustomElement( { instanceId } ) {
return (
<div id={ `my-custom-element-${ instanceId }` }>
content
</div>
);
}
export default withInstanceId( MyCustomElement );
It seems like it is just being used for html ids? As to not have duplicate id names? Is there any other usage for it? If i just export my component using export default withInstanceId( MyCustomElement )
will the entire component have a unique id?