Reputation: 2082
Is there a way to make AngularJS’s ngRoute
work together with react-router
?
Main routing is inside the AngularJS application and I tried to add react-router
for only a small part of the app but it seems to be conflicting with Angular’s routing. (navigating with NavLink
works fine but going back in the browser seems to ignore everything react-router
did).
I have been using AngularJS 1.5.6 or 1.8.x
and react-router v5.2.1
.
Below are some snippets for how the application is layered:
//inside Angular
.when("/newRoute", {
// this is just a react component injected and rendered inside AngularJs
template: ‘<div react-bridged-component data-component-name="RouteView"></div>’,
})
//inside React
const RouteView = () => (
<Suspense fallback={<div>Loading...</div>}>
<BrowserRouter basename="route">
<SomeComponent />
</BrowserRouter>
</Suspense>
);
Upvotes: 1
Views: 500