oedotme / generouted

Generated file-based routes for Vite
https://stackblitz.com/github.com/oedotme/generouted/tree/main/explorer
MIT License
1.02k stars 47 forks source link

Loaders are executed twice when using React.StrictMode #159

Closed ferretwithaberet closed 5 months ago

ferretwithaberet commented 5 months ago

Describe the Bug

React router loaders run twice when using React.StrictMode

Generouted Version

1.18.5

Your Example Website or App or Reproduction

https://stackblitz.com/edit/vitejs-vite-jbnrwj?file=src%2Fmain.tsx&terminal=dev

Steps to Reproduce the Bug or Issue

  1. Make a router with a route that has a Loader;
  2. Add a console.log inside the Loader;
  3. Add React.StrictMode above the Routes component;
  4. Open browser console, navigate to the route and observe the Loader runs twice.

Expected Behavior

The loader should only run once

Screenshots or Videos

No response

Platform

Additional context

Might be related to https://github.com/remix-run/react-router/discussions/10605

oedotme commented 5 months ago

Hey @ferretwithaberet, thanks for opening this issue and providing the related issue. I just released v1.18.7 with the fix.