[v11.1.x] Plugin extensions: Return react components from usePluginComponents() (#89328)
Plugin extensions: Return react components from `usePluginComponents()` (#89237)
feat: return with react components from `usePluginComponents()`
(cherry picked from commit 1d6c9d4690)
Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
This commit is contained in:
co-authored by
Levente Balogh
parent
10e913ac79
commit
5ec9cd017b
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user