Plugin extensions: Return react components from usePluginComponents() (#89237)

feat: return with react components from `usePluginComponents()`
This commit is contained in:
Levente Balogh
2024-06-18 09:40:25 +02:00
committed by GitHub
parent 0cc67bb93d
commit 1d6c9d4690

View File

@@ -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]