跳到主要内容

使用暴露的组件

应用插件可以通过暴露一个 React 组件来提供额外功能,然后这些功能可以导入到你自己的插件中。使用暴露的组件为你的应用插件增强额外功能,以扩展用户工作流。

使用暴露的组件

以下示例展示了如何使用由另一个插件暴露的组件

import { usePluginComponent } from '@grafana/runtime';

export const MyComponent = () => {
const { component: Component, isLoading } = usePluginComponent('myorg-basic-app/reusable-component/v1');

return (
<>
<div>My component</div>
{isLoading ? 'Loading...' : <Component name="John" />}
</>
);
};