Skip to content

not rendered Suspense fallback when change route #48908

@d0hyeon

Description

@d0hyeon

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

react: >= 18
next: >= 12.1.0

Which example does this report relate to?

all

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

not rendered Suspense fallback when change route

function Component () {
  const { query: { page } } = useRouter();
  const { data } = useQuery([page], () => api.get('...', { params: { page } }) );

  return (
    <p>{data}</p>
  )
}

function App () {
  return (
    <Suspense fallback="loading...">
      <Component /> 
    </Suspense>
  )
}

I think it's because of the startTransition of react
https://github.com/vercel/next.js/blob/canary/packages/next/src/client/index.tsx#L518-L522

Expected Behavior

render fallback component

can i perform this when provide startTransition option like priority of next/image?

ex)

function Component () {
  const { query: { page } } = useRouter({ priority: false });
}
function Component () {
  const router = useRouter();
  
  return <button onClick={() => router.push('/', '/', { priority: false })} />
}

To Reproduce

codesandbox

Metadata

Metadata

Assignees

No one assigned

    Labels

    examplesIssue was opened via the examples template.lockedstaleThe issue has not seen recent activity.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions