localize-router
localize-router copied to clipboard
Lazy loaded component is not bootstrapping
I am trying to do routes localization however home component is not bootstrapping on hard refresh also if i any route and do hard refresh get an error - No matches found. But if i click on any link in app.component that uses translated urls they are working. I have clones DEMO project and made home also lazy loaded and it works fine. Can someone help to understand why this might happen?
I have posted this question on Stackoverflow but there is no localize-router tag so I am re-posting it here https://stackoverflow.com/questions/54672738/localize-router-not-bootstrapping-component-on-refresh
I was able to solve this issue and seems like this is not working with initialNavigation: 'enabled' on Router. And this is needed to prevent flickering with SSR.
Also i have an error on SSR: Error: Cannot find module './components/home/home.module.ngfactory' - how this can be solved?
@vytautas-pranskunas- I solved this issue.
Our error was on the imports order on app-routing.module. The Router must be the first import, before LocalizeRouter
@NgModule({
imports: [
RouterModule.forRoot(appRoutes), <---------------- FIRST
LocalizeRouterModule.forRoot(appRoutes)
],
exports: [
RouterModule, <---------------- FIRST
LocalizeRouterModule
]
})
I don't know exactly if it's relevant on the forChild imports and exports but make sense follow the same order.
NOTE: We have SSR implemented
@rafa-as We have import and export for parent app-routing.module, but it's doesn't change anything. Doesn't work.
@vytautas-pranskunas- It's an SSR error. Do you use @nguniversal/module-map-ngfactory-loader
?
This module change "lazy-load" to "simple load" only on server-side.