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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -41,12 +41,14 @@ export function usePluginLinks(options: GetPluginExtensionsOptions): {
export function usePluginComponents<Props = {}>(
options: GetPluginExtensionsOptions
): { components: Array<PluginExtensionComponent<Props>>; isLoading: boolean } {
): { components: Array<React.ComponentType<Props>>; isLoading: boolean } {
const { extensions, isLoading } = usePluginExtensions(options);
return useMemo(
() => ({
components: extensions.filter(isPluginExtensionComponent) as Array<PluginExtensionComponent<Props>>,
components: extensions
.filter(isPluginExtensionComponent)
.map(({ component }) => component as React.ComponentType<Props>),
isLoading,
}),
[extensions, isLoading]