跳到主要内容

使用暴露的组件

应用插件可以通过 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" />}
</>
);
};