Wrapping code in suspense?
Answered
Clumber Spaniel posted this in #help-forum
Clumber SpanielOP
How do i wrap this in suspense?
Answered by chisto
you can make it a component, i usually do this
and inside the component i put all the logic and stuff that was on the Page
export default function Page() {
return (
<Suspense>
<Component />
</Suspense>
);
}
and inside the component i put all the logic and stuff that was on the Page
export default function Page() {
return (
<Suspense>
<Component />
</Suspense>
);
}
10 Replies
you have to wrap the whole component in the parent component
<Suspense>
<ThisComponent />
</Suspense>
<Suspense>
<ThisComponent />
</Suspense>
btw, why do you wrap that code in suspense?
because they used useSearchParams() in SSG
so Suspense is forced
Clumber SpanielOP
Its not a component though, ots in page.tsx
How do i wrap it then?
you can make it a component, i usually do this
and inside the component i put all the logic and stuff that was on the Page
export default function Page() {
return (
<Suspense>
<Component />
</Suspense>
);
}
and inside the component i put all the logic and stuff that was on the Page
export default function Page() {
return (
<Suspense>
<Component />
</Suspense>
);
}
Answer
Clumber SpanielOP
I see, fixed it, thanks
can you mark as solved the answer that helped u most?