Plugin Extensions: Remove react API refs in ComponentWithMeta (#115347)

* maybe better way to attach meta?

* chore(plugin-extensions): remove todo comment

---------

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
Jack Westbrook
2025-12-16 16:59:40 +01:00
committed by GitHub
co-authored by Ashley Harrison
parent c09cb08dec
commit 6eab74a90f
@@ -67,21 +67,15 @@ export function createComponentWithMeta<Props extends JSX.IntrinsicAttributes>(
): ComponentTypeWithExtensionMeta<Props> {
const { component: Component, ...config } = registryItem;
function ComponentWithMeta(props: Props) {
return <Component {...props} />;
}
ComponentWithMeta.displayName = Component.displayName;
ComponentWithMeta.defaultProps = Component.defaultProps;
ComponentWithMeta.propTypes = Component.propTypes;
ComponentWithMeta.contextTypes = Component.contextTypes;
ComponentWithMeta.meta = {
pluginId: config.pluginId,
title: config.title ?? '',
description: config.description ?? '',
id: generateExtensionId(config.pluginId, extensionPointId, config.title),
type: PluginExtensionTypes.component,
} satisfies PluginExtensionComponentMeta;
const ComponentWithMeta: ComponentTypeWithExtensionMeta<Props> = Object.assign(Component, {
meta: {
pluginId: config.pluginId,
title: config.title ?? '',
description: config.description ?? '',
id: generateExtensionId(config.pluginId, extensionPointId, config.title),
type: PluginExtensionTypes.component,
} satisfies PluginExtensionComponentMeta,
});
return ComponentWithMeta;
}