mirror of
https://github.com/vercel/commerce.git
synced 2025-05-19 16:07:01 +00:00
Test to remove suspense from dynamic content manager
This commit is contained in:
parent
74d368531f
commit
0e4cc37ece
@ -7,22 +7,13 @@ import ReusableSection from '@/components/modules/reusable-section/reusable-sect
|
|||||||
import Slider from '@/components/modules/slider/slider';
|
import Slider from '@/components/modules/slider/slider';
|
||||||
import USPSection from '@/components/modules/usp-section/usp-section';
|
import USPSection from '@/components/modules/usp-section/usp-section';
|
||||||
import { InformationCircleIcon } from '@heroicons/react/24/outline';
|
import { InformationCircleIcon } from '@heroicons/react/24/outline';
|
||||||
import { Suspense } from 'react';
|
interface getContentComponentProps {
|
||||||
|
_type: string;
|
||||||
interface dynamicContentManagerProps {
|
_key: number;
|
||||||
content: [] | any;
|
disabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DynamicContentManager = ({ content }: dynamicContentManagerProps) => {
|
const getContentComponent = ({ _type, _key, disabled, ...rest }: getContentComponentProps) => {
|
||||||
return (
|
|
||||||
<div className="dynamic-content overflow-x-hidden">
|
|
||||||
{content?.map(
|
|
||||||
(
|
|
||||||
component: { _type: string; _key: number; disabled: boolean; rest: any } | any,
|
|
||||||
index: number
|
|
||||||
) => {
|
|
||||||
const { _type, _key, disabled, ...rest } = component;
|
|
||||||
|
|
||||||
let Component: any;
|
let Component: any;
|
||||||
|
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
@ -84,20 +75,20 @@ const DynamicContentManager = ({ content }: dynamicContentManagerProps) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Component && index === 0) {
|
return Component ? (
|
||||||
return <Component key={`${_key}`} {...rest} />;
|
<Component key={`${_key}`} {...rest} />
|
||||||
} else if (Component) {
|
) : (
|
||||||
return (
|
<div key={`${_key}`}>Something else</div>
|
||||||
<Suspense key={`${_key}`}>
|
|
||||||
<Component {...rest} />
|
|
||||||
</Suspense>
|
|
||||||
);
|
);
|
||||||
} else {
|
};
|
||||||
<div key={`${_key}`}>Something else</div>;
|
|
||||||
}
|
interface dynamicContentManagerProps {
|
||||||
}
|
content: [] | any;
|
||||||
)}
|
}
|
||||||
</div>
|
|
||||||
|
const DynamicContentManager = ({ content }: dynamicContentManagerProps) => {
|
||||||
|
return (
|
||||||
|
<div className="dynamic-content overflow-x-hidden">{content?.map(getContentComponent)}</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user