router: lazy loading needs a suspense tag

According to the React documentation[0], a suspense tag is needed to
encapsulate a lazy loaded component. Some bad behavior have been fix in
the UI thanks to that tag (i.e notification popup unclosable after
wizard creation).

[0] https://react.dev/reference/react/lazy#suspense-for-code-splitting
This commit is contained in:
Thomas Lavocat 2023-08-17 14:17:04 +02:00 committed by Lucas Garfield
parent d66b013f5b
commit 178791f2ad

View file

@ -1,4 +1,4 @@
import React, { lazy } from 'react';
import React, { lazy, Suspense } from 'react';
import { useFlag } from '@unleash/proxy-client-react';
import { Route, Routes } from 'react-router-dom';
@ -16,8 +16,22 @@ export const Router = () => {
const edgeParityFlag = useFlag('edgeParity.image-list');
return (
<Routes>
<Route path="*" element={<LandingPage />}>
<Route path="imagewizard/:composeId?" element={<CreateImageWizard />} />
<Route
path="*"
element={
<Suspense>
<LandingPage />
</Suspense>
}
>
<Route
path="imagewizard/:composeId?"
element={
<Suspense>
<CreateImageWizard />
</Suspense>
}
/>
<Route path="share/:composeId" element={<ShareImageModal />} />
</Route>