mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat: lazy load playground (#1145)
* feat: lazy load playground * fix: app.tsx * fix: add suspense * fix: update snapshot
This commit is contained in:
parent
3fad1bb230
commit
d4f46eaf2e
@ -14,6 +14,7 @@ import { SplashPageRedirect } from 'component/splash/SplashPageRedirect/SplashPa
|
|||||||
import { useStyles } from './App.styles';
|
import { useStyles } from './App.styles';
|
||||||
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
|
import { Suspense } from 'react';
|
||||||
|
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
const { classes: styles } = useStyles();
|
const { classes: styles } = useStyles();
|
||||||
@ -30,6 +31,7 @@ export const App = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<SWRProvider isUnauthorized={!isLoggedIn}>
|
<SWRProvider isUnauthorized={!isLoggedIn}>
|
||||||
|
<Suspense fallback={<Loader />}>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={!hasFetchedAuth}
|
condition={!hasFetchedAuth}
|
||||||
show={<Loader />}
|
show={<Loader />}
|
||||||
@ -61,6 +63,7 @@ export const App = () => {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
</Suspense>
|
||||||
</SWRProvider>
|
</SWRProvider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -120,7 +120,14 @@ exports[`returns all baseRoutes 1`] = `
|
|||||||
"type": "protected",
|
"type": "protected",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"component": [Function],
|
"component": {
|
||||||
|
"$$typeof": Symbol(react.lazy),
|
||||||
|
"_init": [Function],
|
||||||
|
"_payload": {
|
||||||
|
"_result": [Function],
|
||||||
|
"_status": -1,
|
||||||
|
},
|
||||||
|
},
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
"menu": {
|
"menu": {
|
||||||
"mobile": true,
|
"mobile": true,
|
||||||
|
@ -53,10 +53,10 @@ import { SegmentTable } from 'component/segments/SegmentTable/SegmentTable';
|
|||||||
import FlaggedBillingRedirect from 'component/admin/billing/FlaggedBillingRedirect/FlaggedBillingRedirect';
|
import FlaggedBillingRedirect from 'component/admin/billing/FlaggedBillingRedirect/FlaggedBillingRedirect';
|
||||||
import { FeaturesArchiveTable } from '../archive/FeaturesArchiveTable';
|
import { FeaturesArchiveTable } from '../archive/FeaturesArchiveTable';
|
||||||
import { Billing } from 'component/admin/billing/Billing';
|
import { Billing } from 'component/admin/billing/Billing';
|
||||||
import { Playground } from 'component/playground/Playground/Playground';
|
|
||||||
import { Group } from 'component/admin/groups/Group/Group';
|
import { Group } from 'component/admin/groups/Group/Group';
|
||||||
import { CreateGroup } from 'component/admin/groups/CreateGroup/CreateGroup';
|
import { CreateGroup } from 'component/admin/groups/CreateGroup/CreateGroup';
|
||||||
import { EditGroup } from 'component/admin/groups/EditGroup/EditGroup';
|
import { EditGroup } from 'component/admin/groups/EditGroup/EditGroup';
|
||||||
|
import { LazyPlayground } from 'component/playground/Playground/LazyPlayground';
|
||||||
|
|
||||||
export const routes: IRoute[] = [
|
export const routes: IRoute[] = [
|
||||||
// Splash
|
// Splash
|
||||||
@ -182,7 +182,7 @@ export const routes: IRoute[] = [
|
|||||||
{
|
{
|
||||||
path: '/playground',
|
path: '/playground',
|
||||||
title: 'Playground',
|
title: 'Playground',
|
||||||
component: Playground,
|
component: LazyPlayground,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
type: 'protected',
|
type: 'protected',
|
||||||
menu: { mobile: true },
|
menu: { mobile: true },
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
import { lazy } from 'react';
|
||||||
|
|
||||||
|
export const LazyPlayground = lazy(() => import('./Playground'));
|
@ -212,3 +212,5 @@ export const Playground: VFC<{}> = () => {
|
|||||||
</PageContent>
|
</PageContent>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default Playground;
|
||||||
|
Loading…
Reference in New Issue
Block a user