-
-
Notifications
You must be signed in to change notification settings - Fork 661
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
[TanStack Start] HMR is not working from root route (__root) #1992
Comments
I'm experiencing this as well, not just in my root route but in any top-level route. I also have not been able to separate out |
We just added TanStack router to our vite-based project, and now we are also experiencing this HMR failure. I tried a few different routes, it does seem to only be happening with __root.tsx. |
To summarize, we see the following HMR problems with file based routing: HMR is not triggered when editing
HMR is triggered when editing
ReproductionAll of this can be testet with the Start Basic StackBlitz. Create a new File export function Example() {
return <h1>Changing this will not trigger HMR</h1>
} Now import this into import { createFileRoute } from '@tanstack/react-router'
import { Example } from '~/components/Example'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
<div className="p-2">
<h3>Welcome Home!!!</h3>
<Example />
</div>
)
} While editing "Welcome Home!!!" will trigger HMR, editing "Changing this will not trigger HMR" will not. The latter shows
in the console, but a manual reload is necessary. |
Having the same problem for |
Bump, this happens on routes at random |
can you please test out the package built for this PR whether it fixes the HMR issues you are experiencing: #2286 (comment) |
Installed as above, still had the same issue though. Updates to pages don't hot reload. |
Hmm, yeah looks like I'm not sure how to install your forked version to @tanstack/react-router. |
@schiller-manuel I've tried both #2286 and #2316. Both seem to fix the problem in their current state. @jwtong make sure to unfold the instructions in the comments on how to install from a pr. You can either use "@tanstack/react-router": "https://pkg.pr.new/@tanstack/react-router@2316",
"@tanstack/react-router-with-query": "https://pkg.pr.new/@tanstack/react-router-with-query@2316",
"@tanstack/start": "https://pkg.pr.new/@tanstack/start@2316", Make sure all |
For me, it did not resolve the issue. If I edit a route file (e.g. I tested by just adding content inside a |
It works for me on #2316 (version |
none of those fixed my issue. I'm not using tanstack start, only tanstack router, but i have the exact same problem |
For anyone reading this who's looking for a workaround until a fix is merged, you can add the following to your export const Route = createRootRoute({
// Other route props like the component
// ...
//
scripts: () =>
import.meta.env.DEV
? [
{
type: 'module',
children: `import RefreshRuntime from "/_build/@react-refresh";
RefreshRuntime.injectIntoGlobalHook(window)
window.$RefreshReg$ = () => {}
window.$RefreshSig$ = () => (type) => type`,
},
]
: [],
}); This does the same thing as #2286 and #2316 (albeit in a slightly more hacky way). Once the fix is merged, you should be able to safely remove this code from your |
@MarkSFrancis Lifesaver, been trying to work Start into a side project of mine and was pretty sad about the HMR (but its alpha so who cares). A great fix for now until the team gets it going! |
@MarkSFrancis - worked wonders for me trying to get authentication working, as soon as i added useServerFn everything exploded!! Found this issue and things are rolling again |
Hi, I'm experiencing the same issue with TanStack/Router. HMR doesn't working when I make changes in |
Extracting root route component fixed an issue (thanks Claude): From: createRootRoute({
component: () => (<></>)
}); To: createRootRoute({
component: RootComponent
}); |
For me this was the issue in all routes! bless you |
Currently, while the page is indeed reloaded upon file modification, it does a full page reload instead of a HMR. But this only happens on regular routes, not the __root route (on which HMR works). Using Tanstack Start |
I am experiencing full reload too. Not sure what am i missing. Using Start |
I get type errors when i try to add the script like you did, I tried doing the same thing by replacing scripts with loader or beforeReload but to no avail. i'm using tanstack router( not start) with vite, when I edit and save a component in a file that starts with "-"( inside my routes folder to ignore it) I don't see any changes, not even a full page reload let alone HMR. This is super annoying I guess I can't continue with tanstack router for the time being unfortunately :(( |
Describe the bug
HMR is not working in root route. only working from normal routes.
Your Example Website or App
https://github.com/TanStack/router/tree/main/examples/react/start-basic-rsc
Steps to Reproduce the Bug or Issue
__root.tsx
. I just added a link beside Home.Expected behavior
In terminal, dev server printed a log about page has reloaded.
but the changes are not reflected in the browser.
Screenshots or Videos
2024-07-19.19.22.35.mov
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: