vercel / next.js

The React Framework
https://nextjs.org
MIT License
126.93k stars 26.98k forks source link

useSearchParams and nested Layouts break loading of static assests #52586

Open veithio opened 1 year ago

veithio commented 1 year ago

Verify canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #22 SMP Tue Jan 10 18:39:00 UTC 2023
    Binaries:
      Node: 18.14.2
      npm: 9.5.0
      Yarn: 1.22.19
      pnpm: N/A
    Relevant Packages:
      next: 13.4.10-canary.4
      eslint-config-next: 13.4.8
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.0.4
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

App Router

Link to the code that reproduces this issue or a replay of the bug

https://codesandbox.io/p/sandbox/fancy-microservice-fc28gl?file=%2Fapp%2Fwith%2Fpage.tsx%3A11%2C1

To Reproduce

  1. Navigate to the route /without -> the alert.js is served and the browser shows the alert message
  2. Navigate to the route /with -> the alert.js is not served and the browser does not show the alert message

Describe the Bug

Hi everyone,

I've encountered a problem with useSearchParams and nested layouts: When loading static assets in a page which accesses search params the asset is not loading. Please see the CodeSandbox to reproduce it. Thanks!

Expected Behavior

Both routes should load the alert.js and display the alert message

Which browser are you using? (if relevant)

Chrome Version 114.0.5735.199

How are you deploying your application? (if relevant)

npm run start (edit)

darshanjain-entrepreneur commented 1 year ago

please just clarify what is the problem

darshanjain-entrepreneur commented 1 year ago

I have checked your sandbox the alert.js is working for both with.js and without.js. I don't what problem you are getting

veithio commented 1 year ago

Thanks for checking the problem, when you build the app with npm run build and launch it npm run start the problem occurs as described. Unfortunately I don`t know how to change the setting to start the sandbox with a prod-like build.