Custom React UI Components: Extending Ext JS Components in ReExt
Get a summary of this article:
Off-the-shelf components cover most of what an enterprise app needs, but never all of it. Sooner or later every team needs custom React UI components: a grid with the company’s defaults built in, a status column that renders consistent badges, a field that validates product codes, or a plugin that adds the same behavior to every grid.
With ReExt, which brings Ext JS components into React, you have two ways to build them. This guide covers both, and focuses on the one that gives the most leverage for data-heavy screens: extending Ext JS components themselves, then using them in React like any other component.

Two ways to customize
| Extend in Ext JS | Compose in React | |
|---|---|---|
| How | Define a new Ext JS class with Ext.define, extending an existing component | Write a React component that renders a <ReExt> element with your defaults |
| Best for | Behavior inside the component: renderers, plugins, validators, defaults, methods and events | The API your screens see: props, types, data loading and app integration |
| Reused in | Every Ext JS screen, in React through ReExt, and in existing Ext JS apps | React screens |
| Example | A status column, a SKU validator, a row-count plugin | A typed DataGrid wrapper with feature flags |
The two work best together: extend Ext JS for what happens inside the component, and wrap it in React for the API your teams use. Our guide to building a reusable React UI component around the Ext JS data grid covers the React side. This guide covers the Ext JS side.
Also Read: https://www.sencha.com/blog/5-steps-to-finding-the-best-javascript-libraries/
Setup: where custom classes live and how React loads them
Keep custom Ext JS classes in one folder, organized like an Ext JS app, with an index file that imports them in dependency order:
src/ext/
overrides/DateField.js # app-wide defaults for existing components
vtypes.js # custom validation types
grid/column/Status.js # custom column type
grid/plugin/RowCount.js # custom grid plugin
grid/Standard.js # extended grid with company defaults
index.js # imports everything above, in order
useExtClasses.js # loads the classes once Ext JS is ready// src/ext/index.js: overrides and building blocks first, components that use them last
import './overrides/DateField';
import './vtypes';
import './grid/column/Status';
import './grid/plugin/RowCount';
import './grid/Standard';
The classes call Ext.define, so they must load after ReExtProvider has loaded Ext JS. A small hook does that once and tells React when the custom components are ready:
// src/ext/useExtClasses.js
import { useEffect, useState } from 'react';
let loaded = null; // shared across components, so the classes load only once
export function useExtClasses() {
const [ready, setReady] = useState(false);
useEffect(() => {
loaded = loaded || import('./index');
loaded.then(() => setReady(true));
}, []);
return ready;
}
The examples assume ReExt 1.2.0 with Ext JS 8.0 and the Classic toolkit, set up with ReExtProvider as in our Ext JS grid in React tutorial.
Extend a component: a standard grid
The most common custom component is a grid with your organization’s defaults built in. Extending Ext.grid.Panel gives every screen the same behavior, and adds a method and an event that React can use:
// src/ext/grid/Standard.js
Ext.define('App.grid.Standard', {
extend: 'Ext.grid.Panel',
xtype: 'standardgrid',
// Company defaults for every grid
columnLines: true,
emptyText: 'No records to show',
plugins: [
{ ptype: 'gridfilters' },
{ ptype: 'cellediting', clicksToEdit: 1 },
{ ptype: 'rowcount' }, // the custom plugin defined later in this guide
],
initComponent: function () {
this.callParent();
// Turn a double-click into a business event React can listen for
this.on('rowdblclick', function (view, record) {
this.fireEvent('recordopen', record.getData());
}, this);
},
// A custom method React can call through the ready callback
getSelectedData: function () {
return this.getSelection().map(function (record) { return record.getData(); });
},
});
Three things happen here:
- Defaults. Column lines, the empty-state message and three plugins apply to every standardgrid automatically.
- A business event. Screens don’t need to know which Ext JS event means “open this record.” They listen for recordopen and receive a plain object.
- A custom method. getSelectedData() returns plain objects, so React code never handles Ext JS records directly.
One detail to know: plugins declared on the class apply to every instance. If a screen passes its own plugins in config, it replaces the class’s list rather than adding to it, so keep shared plugins on the class and avoid redefining them per screen.
A custom column type
When the same rendering logic appears in many grids, such as status badges, currency with a symbol from the record, or progress bars, turn it into a column type. Screens then use it by xtype, and the logic lives in one place.
// src/ext/grid/column/Status.js
Ext.define('App.grid.column.Status', {
extend: 'Ext.grid.column.Column',
alias: 'widget.statuscolumn',
width: 120,
align: 'center',
// One mapping from status to color, shared by every grid
colors: {
Open: '#1F5FAA',
Shipped: '#2E7D32',
Closed: '#6B7280',
},
defaultRenderer: function (value) {
var color = this.colors[value] || '#6B7280';
var text = Ext.String.htmlEncode(value || '');
return '<span style="display:inline-block;padding:2px 10px;border-radius:10px;' +
'color:#fff;background:' + color + '">' + text + '</span>';
},
});
Using it is one line in any grid’s column list:
{ text: 'Status', dataIndex: 'status', xtype: 'statuscolumn' }
A few notes:
- defaultRenderer is the method Ext JS column types override to render their cells; it runs with the column as this, so it can read the column’s own settings, such as colors.
- Always encode values that might come from user input before putting them into HTML, as Ext.String.htmlEncode does here.
- Make settings overridable. A screen can pass a different colors map in the column’s config without creating a new class.
Custom validation types and app-wide overrides
A custom validation type
Enterprise apps validate formats that no framework ships with: product codes, account numbers, internal IDs. Ext JS lets you register a validation type, a vtype, once and use it in every field, in forms and grid editors alike:
// src/ext/vtypes.js
Ext.apply(Ext.form.field.VTypes, {
// Product SKUs look like ABC-1234
sku: function (value) {
return /^[A-Z]{3}-\d{4}$/.test(value);
},
skuText: 'Use the format ABC-1234',
skuMask: /[A-Za-z0-9-]/, // keys allowed while typing
});
Any text field can then use it:
{ xtype: 'textfield', fieldLabel: 'SKU', name: 'sku', vtype: 'sku' }
The rule, its error message and its keystroke filter now live in one place, so every form and grid editor that handles SKUs behaves the same way.
App-wide overrides
Sometimes you don’t need a new component, just different defaults for an existing one everywhere in the app. An override changes the class itself:
// src/ext/overrides/DateField.js
Ext.define('App.override.form.field.Date', {
override: 'Ext.form.field.Date',
format: 'M j, Y', // display format used across the app
startDay: 1, // weeks start on Monday
});
Every date field, in every form and grid editor, now uses the company’s date format and week start, without changing a single screen.
Use overrides sparingly. They’re ideal for app-wide defaults like these, but because they change JS framework classes globally, keep them in one folder, document each one, and recheck them when upgrading Ext JS.
A custom grid plugin
Plugins add behavior to a component without subclassing it, so they can be mixed into any grid. This one keeps the grid’s title showing the number of visible rows, updating as users filter:
// src/ext/grid/plugin/RowCount.js
Ext.define('App.grid.plugin.RowCount', {
extend: 'Ext.plugin.Abstract',
alias: 'plugin.rowcount',
init: function (grid) {
this.grid = grid;
this.baseTitle = grid.getTitle() || '';
this.store = grid.getStore();
this.store.on('datachanged', this.updateTitle, this);
this.updateTitle();
},
updateTitle: function () {
var count = this.store.getCount();
this.grid.setTitle(this.baseTitle + ' (' + count + ')');
},
destroy: function () {
if (this.store) {
this.store.un('datachanged', this.updateTitle, this);
}
this.callParent();
},
});
Any grid can use it with { ptype: ‘rowcount’ }, and the standard grid from earlier already includes it.
Good plugin habits:
- Clean up in destroy. Remove every listener the plugin added, so grids that are created and destroyed as users navigate don’t leak memory.
- Do one thing. Small, focused plugins are easier to test and combine than one large plugin with many options.
- Handle changing stores if your grids swap stores at runtime, for example through data binding, by listening for the grid’s store change as well.
Using the custom components in React
With the classes loaded, React screens use them exactly like built-in Ext JS components: by xtype, with configuration and event props. This order screen combines the standard grid, the status column, the SKU validator and the row-count plugin, and talks to React in both directions:
// src/screens/orders/OrdersScreen.tsx
import { useMemo, useRef } from 'react';
import ReExt from '@sencha/reext';
import { useExtClasses } from '../../ext/useExtClasses';
export function OrdersScreen({ orders, onOpen, onBulkAction }) {
const ready = useExtClasses();
const gridRef = useRef<any>(null);
const config = useMemo(() => ({
title: 'Orders',
store: { data: orders },
columns: [
{ text: 'Customer', dataIndex: 'customer', flex: 1, filter: 'string' },
{ text: 'SKU', dataIndex: 'sku', width: 130,
editor: { xtype: 'textfield', vtype: 'sku', allowBlank: false } },
{ text: 'Order date', dataIndex: 'orderDate', width: 140,
xtype: 'datecolumn', format: 'M j, Y', editor: 'datefield' },
{ text: 'Status', dataIndex: 'status', xtype: 'statuscolumn',
filter: { type: 'list', options: ['Open', 'Shipped', 'Closed'] } },
],
}), [orders]);
if (!ready) return <p>Loading…</p>;
return (
<>
<button onClick={() => onBulkAction(gridRef.current?.getSelectedData() ?? [])}>
Process selected
</button>
<ReExt
xtype="standardgrid"
style={{ height: 480 }}
config={config}
ready={(cmp) => { gridRef.current = cmp; }}
onRecordopen={(order) => onOpen(order)}
/>
</>
);
}
How the pieces connect:
| Direction | Mechanism | In this example |
|---|---|---|
| React to component | Props: config and xtype | Orders, columns, the custom column type and validator |
| React to component | Methods through the ready callback | getSelectedData() for the bulk action button |
| Component to React | Custom events as on props | recordopen becomes onRecordopen |
The screen never imports a plugin or writes a renderer. Those live in the custom classes, so every screen that uses standardgrid and statuscolumn gets the same behavior. The date editor also picks up the app-wide date format from the override.
Best practices for custom components
- Use one namespace. Prefix classes with your app or company name, such as App.grid.Standard or Acme.grid.Standard, and give each a clear xtype, ptype or alias. It avoids collisions with Ext JS classes and other teams’ code.
- Extend, don’t edit. Never change Ext JS source files. Extend classes for new components, and use overrides only for app-wide defaults.
- Keep classes small and focused. A column type renders cells; a plugin adds one behavior; a grid class sets defaults. Small pieces combine better than one large class.
- Return plain data to React. Custom methods and events should hand React plain objects, as getSelectedData() and recordopen do, so React code doesn’t depend on Ext JS records.
- Encode user content. Any renderer that builds HTML should encode values with Ext.String.htmlEncode.
- Clean up. Plugins and components that add listeners should remove them in destroy.
- Document every xtype. List each custom component, its options and its events in your component docs or Storybook, so teams find it instead of rebuilding it.
- Test where it lives. Unit-test pure logic, such as validation functions and renderers, and add end-to-end tests for screens that use the components.
- Recheck on upgrades. Overrides and subclasses depend on framework internals. Run them through your tests, and Sencha’s Upgrade Adviser, whenever you move to a new Ext JS version.
- Share them across apps. Put custom classes in a shared package so every React app, and any remaining Ext JS app, uses the same components.
Frequently asked questions
Can I create custom components with ReExt?
Yes. Define a new Ext JS class with Ext.define, extending an existing component, column, field or plugin, load it once Ext JS is ready, and render it in React with <ReExt xtype=”…”>. Its configuration and events work like any built-in component’s.
Should I customize in Ext JS or in React?
Both, for different jobs. Extend Ext JS classes for behavior inside a component, such as renderers, plugins, validators and defaults. Wrap components in React for the API your screens use, such as typed props and data loading.
How do custom Ext JS components send events to React?
Fire a custom event from the component with fireEvent, and listen for it in React with an on prop: an event called recordopen becomes onRecordopen. Pass plain objects in the event so React code doesn’t depend on Ext JS records.
What is an Ext JS override?
An override changes an existing Ext JS class everywhere in the app, without creating a new class. It’s useful for app-wide defaults, such as a date format, but should be used sparingly and rechecked on every upgrade.
Can the same custom components work in existing Ext JS apps?
Yes. Custom classes are standard Ext JS code, so they work in classic Ext JS applications and in React apps through ReExt. That makes them a good way to share behavior while an app moves from Ext JS to React.
Build it once, use it everywhere
Custom React UI components are where an enterprise app’s conventions live: the grid defaults, the status badges, the validation rules and the shared behaviors that make every screen consistent. With ReExt, you can build them as Ext JS classes, with the full power of the framework, and use them in React by xtype, alongside props and events your React code understands.
Next steps: start a 30-day ReExt trial, read Building a Reusable React UI Component Around the Ext JS Data Grid, or see From JavaScript Library to React: Bringing Ext JS into Modern Front Ends.
Every enterprise React team eventually asks the question: should we build our own UI component…
The short answer: No. React is a JavaScript library for building user interfaces. It renders…
There’s no shortage of React component libraries. There is a shortage of honest guidance on…




