DEV Community

Mackrine Awino
Mackrine Awino

Posted on Edited on AI-assisted

Don't Rewrite Your Ext JS App: Replace It One React Screen at a Time

Every few years someone proposes rewriting the old Ext JS front end from scratch. The pitch is always attractive: a modern stack, a clean design system, no more legacy code. And the result is usually the same: the rewrite takes far longer than planned, the old app keeps getting urgent changes in the meantime, and the business ends up maintaining two systems.

I work on an enterprise application with a large Ext JS front end used by pension administrators every day. We are replacing it with React, but not with a rewrite. We are doing it one screen at a time, with React and Ext JS running side by side in the same application. This post explains why I think that is the right call for most teams, and the practical pattern that makes it work.

Why I don't recommend the big rewrite

Ext JS applications tend to share a few traits:

  • They are big. Grids, forms, wizards and reports built up over many years.
  • They encode business rules nobody wrote down. A field that disables itself in one edge case is often the only record of a regulation or a decision made a decade ago.
  • They are used all day by people who know them deeply. Power users rely on keyboard flows and grid behaviour that a new UI can easily break.

A full rewrite has to rediscover all of that before it delivers anything. Until the very end, users get no benefit, and the team gets no feedback.

Incremental replacement flips that. Every new React screen ships on its own, gets used by real people, and teaches you something before you build the next one.

The pattern: let Ext JS host React components

The core idea is simple. Ext JS stays in charge of the application shell: the layout, the navigation and the existing screens. When we build a new screen, or rebuild an old one, we write it in React and mount it inside an Ext JS component.

Here is a minimal host component, using Ext JS's classic toolkit and React 18. It assumes React and ReactDOM are available to the page, for example from your bundle:

// ReactHost.js
Ext.define('App.view.ReactHost', {
    extend: 'Ext.Component',
    xtype: 'reacthost',

    config: {
        reactComponent: null, // the React component to render
        reactProps: null      // props to pass to it
    },

    afterRender: function () {
        this.callParent(arguments);
        this.root = ReactDOM.createRoot(this.getEl().dom);
        this.renderReact();
    },

    renderReact: function () {
        if (this.root) {
            this.root.render(
                React.createElement(this.getReactComponent(), this.getReactProps() || {})
            );
        }
    },

    updateReactProps: function () {
        // re-render when Ext JS code changes the props
        this.renderReact();
    },

    onDestroy: function () {
        if (this.root) {
            this.root.unmount();
            this.root = null;
        }
        this.callParent(arguments);
    }
});
Enter fullscreen mode Exit fullscreen mode

Using it from an existing Ext JS view looks like any other component:

{
    xtype: 'reacthost',
    reactComponent: NominationSummary,
    reactProps: { memberId: 1042 }
}
Enter fullscreen mode Exit fullscreen mode

Three details matter more than they look:

  1. Mount in afterRender, when the DOM element actually exists.
  2. Always unmount in onDestroy. Ext JS destroys components when tabs and windows close. If React is not unmounted, you leak memory and event listeners, and the bug only shows up after hours of use.
  3. Treat props as the only input. When Ext JS needs to change what React shows, it sets new props through the host. React never reaches into Ext JS components directly.

How the two sides talk to each other

Data flowing into React is handled by props. The harder question is how React tells the rest of the application that something happened, for example "the user saved a record, refresh the grid".

Options, from simplest to most structured:

  • Callback props. The host passes a function such as onSaved in reactProps, and the Ext JS view handles it. This is the easiest place to start.
  • DOM custom events. React dispatches a CustomEvent on its root element and Ext JS listens for it. This is useful when the React component should not know who is listening.
  • A shared API layer. Both sides call the same REST endpoints, and after a change the Ext JS store simply reloads. This keeps the two UIs loosely coupled, which is what you want during a long migration.

What I would avoid is sharing mutable state objects between the two frameworks. Ext JS stores and React state have different update models, and keeping them in sync by hand leads to bugs that are hard to reproduce.

Styling without fights

Ext JS ships with heavy global CSS, and it will happily style elements inside your React component. A few habits keep things predictable:

  • Scope React styles with CSS Modules or a single wrapping class on the React root.
  • Do not rely on CSS resets inside the host. Ext JS already sets many base styles.
  • Match the existing theme at first. Users accept a new screen more easily when it looks like it belongs. You can introduce the new design gradually once more of the app is in React.

Which screens to move first

Not every screen is a good first candidate. Good early choices are:

  • New features, since there is nothing to rewrite, only something to build.
  • Read-heavy summary or review screens, where React's rendering model shines and the risk is low.
  • Screens that are already painful to change in Ext JS, because the team feels the benefit immediately.

Leave the most complex data-entry grids and wizards for later, when the team has a shared React component library and a well-tested integration pattern.

Signs the approach is working

You will know incremental migration is on track when:

  • New features are routinely built in React with no special effort.
  • The host component and integration patterns have stopped changing.
  • Removing an old Ext JS screen is a small, boring pull request.

At that point the balance has shifted, and the remaining Ext JS code can be retired screen by screen until the shell itself is the last thing left.

Final thoughts

Legacy front ends are rarely bad because of the framework. They are hard because they hold years of business knowledge. Incremental migration respects that: it lets you modernise while users keep working, and it turns a risky, all-or-nothing project into a steady series of small wins.

If you are maintaining an Ext JS application and weighing a rewrite, I would love to hear how you are approaching it.


I'm Mackrine Awino, a full-stack software engineer in Nairobi working with Java, Jakarta EE, Spring Boot and React. You can find me on LinkedIn and GitHub.

Top comments (0)