1

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>
);
Mirel Vlad
  • 2,032
  • 3
  • 27
  • 35
  • Need to find a way to sync their histories. We use ui-router with react-hybrid plugin, but it would be nice to start converting our react components to use react-router – Chiptus Aug 21 '22 at 07:19

0 Answers0