Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-data-grid
Advanced tools
Excel-like grid component built with React, with editors, keyboard navigation, copy & paste, and the like
react-data-grid is a powerful and feature-rich data grid component for React applications. It provides a wide range of functionalities for displaying, editing, and managing data in a tabular format. It is highly customizable and supports various features such as sorting, filtering, grouping, and more.
Basic Grid
This code demonstrates a basic data grid with three columns: ID, Title, and Count. It displays two rows of data.
import React from 'react';
import ReactDataGrid from 'react-data-grid';
const columns = [
{ key: 'id', name: 'ID' },
{ key: 'title', name: 'Title' },
{ key: 'count', name: 'Count' }
];
const rows = [
{ id: 0, title: 'Example', count: 20 },
{ id: 1, title: 'Demo', count: 40 }
];
function BasicGrid() {
return <ReactDataGrid columns={columns} rows={rows} />;
}
export default BasicGrid;
Editable Grid
This code demonstrates an editable data grid where users can edit the values in the cells. The changes are reflected in the grid's state.
import React from 'react';
import ReactDataGrid from 'react-data-grid';
const columns = [
{ key: 'id', name: 'ID', editable: true },
{ key: 'title', name: 'Title', editable: true },
{ key: 'count', name: 'Count', editable: true }
];
const rows = [
{ id: 0, title: 'Example', count: 20 },
{ id: 1, title: 'Demo', count: 40 }
];
function EditableGrid() {
const [gridRows, setGridRows] = React.useState(rows);
const onGridRowsUpdated = ({ fromRow, toRow, updated }) => {
const updatedRows = gridRows.slice();
for (let i = fromRow; i <= toRow; i++) {
updatedRows[i] = { ...updatedRows[i], ...updated };
}
setGridRows(updatedRows);
};
return (
<ReactDataGrid
columns={columns}
rows={gridRows}
onRowsUpdate={onGridRowsUpdated}
/>
);
}
export default EditableGrid;
Sortable Grid
This code demonstrates a sortable data grid where users can sort the rows by clicking on the column headers. The sorting direction can be ascending or descending.
import React from 'react';
import ReactDataGrid from 'react-data-grid';
const columns = [
{ key: 'id', name: 'ID', sortable: true },
{ key: 'title', name: 'Title', sortable: true },
{ key: 'count', name: 'Count', sortable: true }
];
const rows = [
{ id: 0, title: 'Example', count: 20 },
{ id: 1, title: 'Demo', count: 40 }
];
function SortableGrid() {
const [gridRows, setGridRows] = React.useState(rows);
const [sortColumn, setSortColumn] = React.useState(null);
const [sortDirection, setSortDirection] = React.useState(null);
const onGridSort = (column, direction) => {
const sortedRows = [...gridRows].sort((a, b) => {
if (direction === 'ASC') {
return a[column] > b[column] ? 1 : -1;
} else if (direction === 'DESC') {
return a[column] < b[column] ? 1 : -1;
} else {
return 0;
}
});
setGridRows(sortedRows);
setSortColumn(column);
setSortDirection(direction);
};
return (
<ReactDataGrid
columns={columns}
rows={gridRows}
onGridSort={onGridSort}
sortColumn={sortColumn}
sortDirection={sortDirection}
/>
);
}
export default SortableGrid;
ag-grid-react is a feature-rich data grid component for React applications. It offers a wide range of functionalities including sorting, filtering, grouping, and more. It is highly customizable and supports large datasets efficiently. Compared to react-data-grid, ag-grid-react provides more advanced features and better performance for large datasets.
react-table is a lightweight and flexible data table component for React. It provides basic functionalities such as sorting, filtering, and pagination. It is highly customizable and easy to use. Compared to react-data-grid, react-table is more lightweight and easier to integrate but may lack some advanced features.
material-table is a data table component for React based on Material-UI. It provides functionalities such as sorting, filtering, grouping, and more. It is highly customizable and integrates well with Material-UI components. Compared to react-data-grid, material-table offers a more modern and visually appealing design but may have a steeper learning curve.
npm install react-data-grid
react-data-grid is published as ES2019 modules, you'll probably want to transpile those down to scripts for the browsers you target using Babel and browserslist.
last 2 chrome versions
last 2 edge versions
last 2 firefox versions
last 2 safari versions
See documentation
{
"presets": [
[
"@babel/env",
{
"bugfixes": true,
"shippedProposals": true,
"corejs": 3,
"useBuiltIns": "entry"
}
]
]
}
See documentation
babel.config.*
instead of .babelrc.*
, otherwise Babel might not transpile modules under node_modules
.import 'core-js/stable';
env
preset, if configured correctly, will transform this import so only the necessary polyfills are included in your bundle.ResizeObserver
API is required for older browsers.{
// ...
module: {
rules: {
test: /\.js$/,
exclude: /node_modules[/\\](?!react-data-grid[/\\]lib)/,
use: 'babel-loader'
}
}
}
See documentation
{
// ...
plugins: {
babel({
include: ['./src/**/*', './node_modules/react-data-grid/lib/**/*']
});
}
}
See documentation
import DataGrid from 'react-data-grid';
const columns = [
{ key: 'id', name: 'ID' },
{ key: 'title', name: 'Title' }
];
const rows = [
{ id: 0, title: 'Example' },
{ id: 1, title: 'Demo' }
];
function App() {
return <DataGrid columns={columns} rows={rows} />;
}
FAQs
Feature-rich and customizable data grid React component
The npm package react-data-grid receives a total of 100,415 weekly downloads. As such, react-data-grid popularity was classified as popular.
We found that react-data-grid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.