Support for multiple router instances (nested RouteProviders) #8284
Replies: 1 comment 1 reply
|
I think this might be related to #7921. That issue hits an invalid hook call rather than the duplicated layout here, but the underlying HMR behavior looks pretty similar. The Vite HMR code checks window.TSR_ROUTER even during the initial route-module import in dev. So if the inner root is loaded while that global points to the outer router, it can end up updating the wrong route. That could also explain why the outer header shows up again in the inner router in your screenshot. #7937 was superseded by #8277, which is still open and changes this area so route updates stay associated with the router that owns the route. I wouldn't use window.TSR_ROUTER = undefined as a permanent workaround though. I'd first try the same setup with a production build/preview. If the duplicate only happens in dev, that would point pretty strongly at the router plugin/HMR path rather than nested RouterProviders themselves. |

I think this might be related to #7921. That issue hits an invalid hook call rather than the duplicated layout here, but the underlying HMR behavior looks pretty similar.
The Vite HMR code checks window.TSR_ROUTER even during the initial route-module import in dev. So if the inner root is loaded while that global points to the outer router, it can end up updating the wrong route. That could also explain why the outer header shows up again in the inner router in your screenshot.
#7937 was superseded by #8277, which is still open and changes this area so route updates stay associated with the router that owns the route.
I wouldn't use window.TSR_ROUTER = undefined as a permanent workaround …