3 ms·
The approach outlined above is the approach I would take (and have previously taken). Some details that I personally think are important: Step 0. Setup typescr
by yazaddaruvala 4y ago
The approach outlined above is the approach I would take (and have previously taken). Some details that I personally think are important:
Step 0. Setup typescript with version control for your current JS mess.
Step 1. FWIW, with ReactDOM.renderToString you can use JSX as your template engine.
Step 2. Move all of your PHP views to JSX views, PHP keeps returning JSON.
Step 3. Abuse component.unmount(); component = ReactDOM.createRoot(…); to get components with view state, but also can get updated by regular JS events that require a rerender just like you would with the legacy jQuery code.
Step 4. Keep pushing more of the logic from the legacy jQuery code and PHP code into React/Typescript. You’ll find that the React components will keep getting grouped and you can start to compose more of the widgets together.
Step 5. You end up with one big React app, minimal PHP (that is easy to test), and a decision about how to manage your state.
At this point it’ll be in shape to not need a lot of attention. Truly, the DB mess will figure itself out as your PHP continually becomes minimal and well tested.