Next.js Discord

Discord Forum

Force to view loading component of page?

Unanswered
Champagne D’Argent posted this in #help-forum
Open in Discord
Champagne D’ArgentOP
Is there a way to force my app to show the loading page? I want to update my loading page but right now I always have to clear the cache and reload which is a pain. Any ideas how I can somehow "force" it to show the loading component?

11 Replies

Siberian Flycatcher
Hey 👋

function sleep(t) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve();
    }, t);
  });
}

export default async function Page() {
  await sleep(10000) // will render closest Suspense / loading.js for 10 seconds

  //rest of the code
}
Champagne D’ArgentOP
@Siberian Flycatcher so this behavior is known?
@Champagne D’Argent <@707695420721201153> so this behavior is known?
Champagne D’ArgentOP
@Ray I am confused now 😄
why?
Champagne D’ArgentOP
so is it due to the loading component?
Champagne D’ArgentOP
I debugged it a bit and the loading state which occurs comes from the main loading.tsx file, also I tried to use "use client" on that file, but same behavior
suspended keeps toggle once I click on a menu. So this is expected?
Champagne D’ArgentOP
I think I got it I used an async in my component with no reason, that fixed it