DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk3 min

Build a React Pivot Table with Persistent State

Learn the controlled-state pattern for adding a drag-and-drop pivot table to React, plus when to add Plotly or choose a table framework or PivotGrid.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To add an interactive pivot table to a React app, install react-pivottable, pass it tabular data, and save every configuration change from its onChange callback in React state. Then pass that saved configuration back to the component. This controlled-state pattern keeps users’ field placements and selections in sync with your app.

Build a basic pivot table with react-pivottable

The react-pivottable project describes a React interface for exploring and summarizing data in tables or charts, using a two-dimensional drag-and-drop layout. For a table-only setup, follow this sequence:

As an Amazon Associate I earn from qualifying purchases.

  1. Install the package and React dependencies: run npm install --save react-pivottable react react-dom.
  2. Import the component and stylesheet: import PivotTableUI from react-pivottable and react-pivottable/pivottable.css into your app.
  3. Prepare the records: provide data in a format supported by the component. The project README demonstrates an array of arrays with a header row; check its input-format documentation against the shape of your production data.
  4. Save configuration changes: in onChange, store the updated pivot configuration in React state or your application’s state store.
  5. Pass the saved configuration back: spread the current state into PivotTableUI, along with the data and callback.

The project README calls PivotTableUI a “dumb component”: it keeps essentially no state of its own. Your app therefore needs to retain the configuration and feed it back on each render. Here is the core pattern in a class component:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import React from 'react';
import PivotTableUI from 'react-pivottable/PivotTableUI';
import 'react-pivottable/pivottable.css';

class SalesPivot extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  render() {
    return (
      <PivotTableUI
        data={this.props.data}
        onChange={state => this.setState(state)}
        {...this.state}
      />
    );
  }
}

export default SalesPivot;

Give data the records in the component’s supported format. The example leaves the initial configuration empty so the user can arrange fields; you can instead initialize state with a configuration if the view should open in a predefined layout. Keep the callback’s updated configuration in the same state source you spread back into the component.

Add charts only when the interface needs them

Table renderers are enough for a basic integration. The README also documents optional Plotly chart output, which adds dependencies and a build decision:

  • Install react-plotly.js and plotly.js.
  • Import the Plotly React component and TableRenderers, then create Plotly renderers with createPlotlyRenderers(Plot).
  • Pass the table and Plotly renderers together to PivotTableUI.

The Plotly React component is injected into the renderer setup. For webpack builds, the project README flags Plotly bundling considerations and also shows an option using an external window.Plotly. Check the project documentation for the setup that matches your build; charts are not required for a table-only pivot.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose a component based on the analysis users need

A full drag-and-drop pivot interface is not necessary for every grouped table. These options differ in how users arrange data and how much analysis functionality they document:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Approach What the documentation describes Consider it when
react-pivottable Drag-and-drop pivot layout, table summaries, and optional Plotly chart renderers. Users should move fields around and explore summaries themselves.
React Table v6 pivoting pivotBy, custom aggregation functions, sorting pivoted columns, and filtering. Grouped rows and aggregates within a table framework meet the need; users do not require a dedicated drag-and-drop pivot layout.
Syncfusion React PivotView Field reorganization, member filtering, hierarchy drilling, and configurable server-side aggregation, filtering, sorting, and grouping. The workflow needs broader analysis features, including server-side processing or hierarchy exploration.
DevExpress React PivotGrid Sorting, header filtering, and XLSX export in its getting-started documentation. Those documented analysis and export controls align with the app’s requirements.

React Table v6 documentation describes a specific version; verify the intended package version before using its API. For fuller PivotGrid products, verify current licensing, pricing, and compatibility directly with the vendor. The cited documentation supplies feature examples, not a complete current compatibility or pricing matrix: React Table v6 pivoting, Syncfusion React PivotView, and DevExpress React PivotGrid.

Check these requirements before choosing

  • Field arrangement: must end users drag fields between rows, columns, and values, or is a fixed grouped table sufficient?
  • Analysis depth: do users need custom aggregation, filtering, sorting, or hierarchy drilling?
  • Processing location: will the browser process the dataset, or must aggregation and filtering happen server-side?
  • Output: is a table enough, or are charts and exports part of the workflow?
  • Integration constraints: check compatibility with your React version and build system, especially if adding Plotly.
  • Commercial terms: confirm current licensing and pricing for a vendor product before adoption.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.