@stramien/react 0.13.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +25 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -52,6 +52,31 @@ export function Example({ rows }: { rows: Row[] }) {
52
52
  call `api.refreshCells()` to apply it immediately.
53
53
  - Get the grid API from `onGridReady={(e) => …e.api}`.
54
54
 
55
+ ### Keep `columnDefs` (and `rowData`) stable
56
+
57
+ Because props are compared by identity, an array written inline in JSX is a new value on every render, and the grid applies the column definitions again each time. It keeps the user's widths, order and pinning, but it does needless work and re-renders the header. Define columns outside the component, or memoize them:
58
+
59
+ ```tsx
60
+ const columnDefs: ColumnDefItem<Device>[] = [
61
+ { field: 'name', filter: 'text' },
62
+ { field: 'lastSeen', ...relativeTimeColumn({ locale: 'nl' }) },
63
+ ];
64
+
65
+ function Devices({ devices }: { devices: Device[] }) {
66
+ // Or, when columns depend on props or state:
67
+ // const columnDefs = useMemo(() => [...], [locale]);
68
+ return (
69
+ <StramienGrid rowData={devices} columnDefs={columnDefs} getRowId={({ data }) => data.id} />
70
+ );
71
+ }
72
+ ```
73
+
74
+ The same goes for `rowData`: pass the array from state, not `items.map(...)` in JSX, so the grid only compares data when it really changed. Callbacks (`getRowId`, `getRowHeight`, `getRowHref`, event handlers) can stay inline: the adapter wraps them.
75
+
76
+ ### React 19 and Tailwind CSS
77
+
78
+ The adapter works with React 18 and 19, including StrictMode's double mount. With Tailwind, declare the cascade layer order so Tailwind's preflight doesn't reset the grid's buttons and inputs: see [Using Stramien with Tailwind CSS](../../docs/theming.md#using-stramien-with-tailwind-css-or-another-css-reset). The grid has no Tailwind dependency; style it through the `--st-*` tokens or with utilities on a wrapper element.
79
+
55
80
  ### Custom cell renderers
56
81
 
57
82
  `cellRenderer` and `detailCellRenderer` accept React components (function components,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stramien/react",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "description": "React 18/19 adapter for Stramien with Portal-based custom cell and Master-Detail renderers",
5
5
  "license": "MIT",
6
6
  "author": "Erik-Jan van Baaren <erikjan@gmail.com>",
@@ -40,7 +40,7 @@
40
40
  "README.md"
41
41
  ],
42
42
  "dependencies": {
43
- "@stramien/core": "0.13.1"
43
+ "@stramien/core": "0.14.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "react": ">=18.0.0",