Closed quentincaffeino closed 4 years ago
Would a _fallback.svelte
solve this?
As a temporary drop-in, I think yes. But what if I would need to have actual fallback. It would render on each mf unmount, right?
You can have multiple fallbacks covering different scopes. I don't fully understand the issue.
Microfrontend website is a wesite where you have multiple applications (often) written in different frameworks. Each is registered in root application which mounts and unmouts different mfs based on registered routes. Lets say application has three routes: /a /b /c. First mf covers first two routes - /a and /b, second mf covers /c. So when we go to url /a or /b first mf is mounted on the page by root application and it should render page A or page B. If we go to /c then root application has to unmount current mf and mount mf which corresponds to new address.
Root application is based on single-spa framework specifically made to create microfrontend applications. Right now all of my mfs are written in svelte but when overs will join they don't have to stick to that.
What happens is when I switch from /a to /c, routify in my first mf reacts fast enough before unmount and tries to render page /c and throws an error.
Hope this would help understand the issue.
I think my confusion is on how the fallback falls short.
Another option is Routify 2's urlTransform
.
config.urlTransform = {
apply: url => url.match(routifysBasepath) ? url : null
remove: url => url,
}
Fallback page is a good option till I need to use it for some actual reason. Guess I'll stick to it for now. Also since I couldn't find anything about urlTransform anywhere nor in docs or this repo, except few a issues, guess it's in development.
I think this issue is resolved then. Thanks for help.
urlTransform
has yet to be documented, but there's mention of it here. https://routify.dev/blog/routify-2
Not sure how urlTransform would help, but I guess fallback page is more than enough.
urlTransform transform the public url to an internal url. By returning null on navigation outside Routify, Routify stays on the existing page.
Can we consider this closed @quentincaffeino ? Is your issue solved?
Yes, thanks for helping.
First thank you for this project, this router is the only one that worked for my project. I'm creating a microfrontend application.
General application routing is handled by other package which mounts and unmounts different microfrontends based on its own routing. Several microfronends have their routing for which I use this package.
Is your feature request related to a problem? Please describe. When I switch between microfrontends before previous is unmounted or when there are multiple on the page, all of of them throw an exception that route doesn't exist (if it isn't their route of course). This doesn't make any problem because package managing mfs handles this error and still successfully unmounts mf. I'm writing because of the noise it creates in the console.
Describe the solution you'd like An option to hide this error.