-
Notifications
You must be signed in to change notification settings - Fork 52
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
Changes to routes containing loaders in dev mode causes router to stop functioning #5
Comments
Glad to hear that! Although I've not noticed that in the examples before, but I encountered similar behavior in other projects, this happens because of the page multiple exports which breaks Vite's HMR at the moment, there's a related issue reported. There was an experimental HMR partial accept added to Vite v3 recently addressing that. Partial accept discussion However, I found one of the following points would get HMR to work: Exporting only Capitalized functions/componentsThat would require changing // src/pages/posts/[slug].tsx
// ...
export const Loader = () => {}
export const Pending = () => {}
export const Failure = () => {}
export default function Post() {} Upgrading to Vite v3+ and enabling experimental partial accept:// vite.config.ts
// ...
export default defineConfig({
plugins: [react()],
experimental: { hmrPartialAccept: true },
}) Adding this line at the end of each page module: // src/pages/posts/[slug].tsx
// ...
export const loader = () => {}
export const pending = () => {}
export const error = () => {}
export default function Post() {}
if (import.meta.hot) import.meta.hot.acceptExports('default') I'm thinking of changing Or maybe add a tiny plugin to inject this Would love to hear what you guys think! |
Hi @oedotme - just got a chance to follow up here and I see you've already made a new release with the change to capitalize those functions - thanks! I would have voted for that option as well - sure it's a departure from how Remix/upcoming React Router version does it (since that's where I'm sure most devs will be coming from when they go searching for better options and hopefully find Tested it out with the new version and everything is working great - thanks again for the quick turnaround and the wonderful library! |
Thrilled to have found this library - pretty much exactly what I was looking for! One minor thing I've found thus far is it seems that changing a route that contains a loader such as
posts/[slug].tsx
in thedata-loaders
example while it's running in dev mode causes the router to stop functioning and a reload is necessary to get things working again. It happens with any route that contains a loader based on my experimentation, not just child routes. Any idea what that could be?The text was updated successfully, but these errors were encountered: