|
1 | 1 | # ReactPivot # |
2 | 2 |
|
3 | | -ReactPivot is a data-grid component with pivot-table-like functionality for data display, filtering, and exploration. Can be used without React. |
| 3 | +ReactPivot is a data-grid component with pivot-table-like functionality for data display, filtering, and exploration. |
| 4 | + |
| 5 | +**Now compatible with React 19+ and modern build tools!** |
4 | 6 |
|
5 | 7 | Demo: [http://davidguttman.github.io/react-pivot/](http://davidguttman.github.io/react-pivot/) |
6 | 8 |
|
7 | 9 |  |
8 | 10 |
|
9 | 11 | ## Installation & Usage ## |
10 | 12 |
|
11 | | -<strong> Default (Browserify/webpack): </strong> |
12 | | - |
| 13 | +```bash |
| 14 | +npm install react-pivot |
13 | 15 | ``` |
14 | | -npm i -S react-pivot |
15 | | -``` |
16 | | - |
17 | | -```js |
18 | | -var React = require('react') |
19 | | -var ReactPivot = require('react-pivot') |
20 | 16 |
|
21 | | -React.render( |
22 | | - <ReactPivot rows={rows} |
23 | | - dimensions={dimensions} |
24 | | - reduce={reduce} |
25 | | - calculations={calculations} |
26 | | - nPaginateRows={25} />, |
27 | | - document.body |
| 17 | +### Modern ES Modules (Recommended) |
| 18 | + |
| 19 | +```jsx |
| 20 | +import React from 'react' |
| 21 | +import { createRoot } from 'react-dom/client' |
| 22 | +import ReactPivot from 'react-pivot' |
| 23 | + |
| 24 | +const root = createRoot(document.getElementById('root')) |
| 25 | +root.render( |
| 26 | + <ReactPivot |
| 27 | + rows={rows} |
| 28 | + dimensions={dimensions} |
| 29 | + reduce={reduce} |
| 30 | + calculations={calculations} |
| 31 | + nPaginateRows={25} |
| 32 | + /> |
28 | 33 | ) |
29 | 34 | ``` |
30 | 35 |
|
31 | | -<strong> Classic (no React or Browserify): </strong> |
| 36 | +### CommonJS (Legacy Support) |
32 | 37 |
|
33 | | -Download [react-pivot-standalone-3.0.0.min.js](https://raw.githubusercontent.com/davidguttman/react-pivot/master/dist/react-pivot-standalone-3.0.0.min.js) |
| 38 | +```js |
| 39 | +const React = require('react') |
| 40 | +const { createRoot } = require('react-dom/client') |
| 41 | +const ReactPivot = require('react-pivot') |
34 | 42 |
|
35 | | -```html |
36 | | -<script src='react-pivot-standalone-3.0.0.min.js'></script> |
37 | | -<script> |
38 | | - ReactPivot(document.body, { |
| 43 | +const root = createRoot(document.getElementById('root')) |
| 44 | +root.render( |
| 45 | + React.createElement(ReactPivot, { |
39 | 46 | rows: rows, |
40 | 47 | dimensions: dimensions, |
| 48 | + reduce: reduce, |
41 | 49 | calculations: calculations, |
42 | | - reduce: reduce |
| 50 | + nPaginateRows: 25 |
43 | 51 | }) |
44 | | -</script> |
45 | | -``` |
46 | | - |
47 | | -<strong> Custom (Browserify, no React): </strong> |
48 | | - |
49 | | -```js |
50 | | -var ReactPivot = require('react-pivot/load') |
51 | | - |
52 | | -ReactPivot(document.body, { |
53 | | - rows: rows, |
54 | | - dimensions: dimensions, |
55 | | - reduce: reduce, |
56 | | - calculations: calculations |
57 | | -}) |
58 | | - |
| 52 | +) |
59 | 53 | ``` |
60 | 54 |
|
| 55 | +### UMD (Browser Global) |
61 | 56 |
|
| 57 | +```html |
| 58 | +<script src="https://unpkg.com/react-pivot/dist/react-pivot.umd.js"></script> |
| 59 | +<script> |
| 60 | + const root = ReactDOM.createRoot(document.getElementById('root')) |
| 61 | + root.render( |
| 62 | + React.createElement(ReactPivot, { |
| 63 | + rows: rows, |
| 64 | + dimensions: dimensions, |
| 65 | + calculations: calculations, |
| 66 | + reduce: reduce |
| 67 | + }) |
| 68 | + ) |
| 69 | +</script> |
62 | 70 | ## Example ## |
63 | 71 |
|
64 | | -```js |
65 | | -var React = require('react') |
66 | | -var ReactPivot = require('react-pivot') |
67 | | - |
68 | | -React.render( |
69 | | - <ReactPivot rows={rows} |
70 | | - dimensions={dimensions} |
71 | | - reduce={reduce} |
72 | | - calculations={calculations} />, |
73 | | - document.body |
| 72 | +```jsx |
| 73 | +import React from 'react' |
| 74 | +import { createRoot } from 'react-dom/client' |
| 75 | +import ReactPivot from 'react-pivot' |
| 76 | + |
| 77 | +const root = createRoot(document.getElementById('root')) |
| 78 | +root.render( |
| 79 | + <ReactPivot |
| 80 | + rows={rows} |
| 81 | + dimensions={dimensions} |
| 82 | + reduce={reduce} |
| 83 | + calculations={calculations} |
| 84 | + /> |
74 | 85 | ) |
75 | 86 | ``` |
76 | 87 |
|
|
0 commit comments