-
Notifications
You must be signed in to change notification settings - Fork 26.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
template.js not executing on every request #60032
Comments
Also experiencing this issue. |
It seems like only a change in immediate child segment triggers template re-rendering. (For example, I wonder if that's how it's supposed to work. |
@aramikuto
and it mentions logging page views which you cannot do if it is not executing on every navigation.
Reference: File Conventions: template.js | Next.js |
I have same issue, I expected that the template is recreated on every navigation but it seems that is not a case for the nested routes. |
Experiencing this problem as well. My expectation would have been the same: when there is a top-level template.tsx, I'd have expected to see the logging on every navigation, whether it is nested or not. |
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/cool-lamport-rnwm47
To Reproduce
Have a file structure that looks like this:
/app
│ layout.js
│ template.js
│ /profile
└─/website
│ │ /view
│ │ /edit
Current vs. Expected behavior
Current behavior:
When navigation between profile and website/view or profile and website/edit the console.log writes 'Template.jsx executed' every single time the route is changes
When navigation between website/view and website/edit the console.log writes 'Template.jsx executed' only the first time. if you continue to navigation between website/view and website/edit console.log will not write 'Template.jsx executed'
Expected behavior:
the console.log writes 'Template.jsx executed' every single time the route is changes
e.g. navigation between website/view and website/edit AND navigation between profile and website/view
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023 Binaries: Node: 20.9.0 npm: 9.8.1 Yarn: 1.22.19 pnpm: 8.10.2 Relevant Packages: next: 14.0.4 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
App Router
Additional context
No response
The text was updated successfully, but these errors were encountered: