review fixes for plugin wrapper blueprint

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2026-01-20 00:11:46 +01:00
parent 768b588203
commit a1be5e1770
2 changed files with 11 additions and 15 deletions
@@ -14,12 +14,6 @@
* limitations under the License.
*/
/**
* Alpha exports for plugin wrapper functionality.
*
* @alpha
*/
export { PluginWrapperBlueprint } from './blueprints/PluginWrapperBlueprint';
export {
type PluginWrapperApi,
@@ -15,7 +15,7 @@
*/
import { PluginWrapperApi } from '@backstage/frontend-plugin-api/alpha';
import { ComponentType, ReactNode, useEffect, useState } from 'react';
import { ComponentType, ReactNode, useEffect, useMemo, useState } from 'react';
type WrapperInput = {
loader: () => Promise<{ component: ComponentType<{ children: ReactNode }> }>;
@@ -86,17 +86,19 @@ export class DefaultPluginWrapperApi implements PluginWrapperApi {
throw error;
}
if (!loadedWrappers) {
return null;
}
return useMemo(() => {
if (!loadedWrappers) {
return null;
}
let content = props.children;
let current = props.children;
for (const Wrapper of loadedWrappers) {
content = <Wrapper>{content}</Wrapper>;
}
for (const Wrapper of loadedWrappers) {
current = <Wrapper>{current}</Wrapper>;
}
return <>{content}</>;
return current;
}, [loadedWrappers, props.children]);
};
composedWrappers.set(pluginId, ComposedWrapper);