move suspense around lazy component (#26333)

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
Erik Jan de Wit 2024-01-19 13:00:56 +01:00 committed by GitHub
parent f20de396aa
commit 84b2c5eb61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,11 +37,7 @@ const ContentComponent = () => {
[content, componentId],
);
return (
<Suspense fallback={<Spinner />}>
{modulePath && <Component modulePath={modulePath} />}
</Suspense>
);
return modulePath && <Component modulePath={modulePath} />;
};
type ComponentProps = {
@ -52,7 +48,11 @@ const Component = ({ modulePath }: ComponentProps) => {
const Element = lazy(
() => import(joinPath(environment.resourceUrl, modulePath)),
);
return <Element />;
return (
<Suspense fallback={<Spinner />}>
<Element />
</Suspense>
);
};
export default ContentComponent;