I am building an application to showcase the usage of the Suspense in Nextjs 13. But the Suspense fallback is not showing while loading.
Here is the page.js
import React, { Suspense } from "react"; import Loading from "./loading"; const Trending = React.lazy(() => import("./Trending")); function Page() { return ( <div> <Suspense fallback={<Loading />}> <Trending /> </Suspense> </div> ); } export default Page; Here is the Trending
import axios from "axios"; export default async function Trending() { const res = await axios.get( `https://api.themoviedb.org/3/trending/movie/day?api_key=1428e09fe38be9df57355a8d6198d916` ); const data = res.data; // Add a delay to ensure that the Suspense fallback is shown await new Promise((resolve) => setTimeout(resolve, 3000)); return ( <div> <li>{data.results[0].title}</li> </div> ); } If you need anything else let me know.
I tried various method such as lazy loading, adding delay and all but still not working. I need to see the fallback component showing while loading the data.