mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugin extensions: Return react components from usePluginComponents()
(#89237)
feat: return with react components from `usePluginComponents()`
This commit is contained in:
parent
0cc67bb93d
commit
1d6c9d4690
@ -41,12 +41,14 @@ export function usePluginLinks(options: GetPluginExtensionsOptions): {
|
|||||||
|
|
||||||
export function usePluginComponents<Props = {}>(
|
export function usePluginComponents<Props = {}>(
|
||||||
options: GetPluginExtensionsOptions
|
options: GetPluginExtensionsOptions
|
||||||
): { components: Array<PluginExtensionComponent<Props>>; isLoading: boolean } {
|
): { components: Array<React.ComponentType<Props>>; isLoading: boolean } {
|
||||||
const { extensions, isLoading } = usePluginExtensions(options);
|
const { extensions, isLoading } = usePluginExtensions(options);
|
||||||
|
|
||||||
return useMemo(
|
return useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
components: extensions.filter(isPluginExtensionComponent) as Array<PluginExtensionComponent<Props>>,
|
components: extensions
|
||||||
|
.filter(isPluginExtensionComponent)
|
||||||
|
.map(({ component }) => component as React.ComponentType<Props>),
|
||||||
isLoading,
|
isLoading,
|
||||||
}),
|
}),
|
||||||
[extensions, isLoading]
|
[extensions, isLoading]
|
||||||
|
Loading…
Reference in New Issue
Block a user