Moving to React one screen at a time
I’ve moved legacy code to React and also added React screens inside existing apps. Here’s how I decide when to keep the old routing in place.
What still needs to work tomorrow?
I’ve worked on AngularJS 1.6 and several Angular versions, including 5, 6, and 8. For some new features, I kept the existing router in place and mounted React inside a wrapper.
Say you’re adding a reports screen. Start by deciding who owns the URL. I’d let the existing router open the screen and let React own what happens inside it. I’d keep the wrapper small enough to understand what it passes in, what React sends back, and what gets cleaned up when someone leaves.
Test the handoff before adding another screen
- Open the new screen from existing navigation, then open its URL directly and refresh it.
- Move between an old screen and the new one using Back and Forward. Check that the URL and the screen always agree.
- Leave the new screen and open it again. Check that listeners and requests from the first visit don’t run twice or change the next screen.
If every new screen needs more shared state or navigation logic in the wrapper, I revisit the boundary. That’s when I’d consider moving a whole feature area together.