CategoryNon classé

React Data Grid: fast setup, editing, sorting & filtering





React Data Grid Guide — fast setup, editing, sorting & filtering


React Data Grid: fast setup, editing, sorting & filtering

A practical, example-driven guide to using react-data-grid (adazzle) for interactive tables, spreadsheet-like editing, filtering, and large data performance.

Why choose react-data-grid (adazzle)?

React-data-grid (the adazzle project) is a purpose-built React grid component optimized for performance and developer ergonomics. Unlike lightweight « table wrappers », it includes built-in support for virtualized rendering, row and cell editing, column resizing, and event hooks—so you get spreadsheet-like behavior with a small API surface.

Choose this library when you need more than a presentational React table component—for example, when you require interactive editing, reliable client-side sorting and filtering, keyboard navigation, or millions of rows through virtualization. Its design focuses on predictable rendering and explicit control over state, which suits complex data-driven apps.

Practically, react-data-grid integrates with common React patterns (hooks, controlled components, and external state managers) and exposes extension points for custom cell renderers, editors, and formatters. That makes it a solid choice for dashboards, admin panels, and internal tools where productivity and UX matter.

Installation and quick setup

Install the package and peer dependencies using your package manager. For npm:

npm install react-data-grid
# or with pnpm / yarn
pnpm add react-data-grid
yarn add react-data-grid

After installing, import and render a minimal grid. The component expects a columns array and row data. Here’s an intentionally tiny example you can drop into any React app:

import React from 'react';
import DataGrid from 'react-data-grid';

const columns = [
  { key: 'id', name: 'ID' },
  { key: 'title', name: 'Title' },
  { key: 'count', name: 'Count' }
];

const rows = [
  { id: 1, title: 'First', count: 10 },
  { id: 2, title: 'Second', count: 20 }
];

export default function App() {
  return <DataGrid columns={columns} rows={rows} />;
}

If you need a guided react-data-grid tutorial, this walkthrough covers interactive editing and filtering with examples and context.

Core concepts: columns, rows, editors, and events

Columns define presentation and behavior. Each column object can include a key, name (header), width, sortable, resizable, and a custom formatter or editor. Column-level metadata is how you enable editing or custom renders without hacking cell internals.

Rows are plain objects or arrays that map to column keys. The component keeps an internal representation of the viewport; you control data changes by providing a new rows array (controlled mode) or by using provided callbacks to update state. This explicit flow avoids subtle re-render bugs.

Editors and formatters are React components you pass into column props to customize cell UI. Typical patterns include inline text editors, dropdowns, and date pickers. Events like onRowsChange, onSelectedRowChange, and onSort let you wire server-side operations or client-side state transitions.

Sorting, filtering, and in-grid editing

Sorting is typically implemented by enabling sortable on columns and handling an onSort or by providing a sorted rows array. For large datasets, sorting on the server is recommended; the grid provides the UI hooks and sort descriptors (column key + direction) so your app can request sorted pages.

Filtering can be client-side (fast for small datasets) or server-driven. Implementing a filter row or custom filter components per column lets users craft precise queries. Combine filter descriptors with pagination or virtualization to keep memory usage low.

In-grid editing supports keyboard navigation, commit/cancel semantics, and custom validation. Use onRowsChange to persist edits to your state or backend. For spreadsheet-like behavior, combine custom editors with keyboard event handlers to implement Enter/Tab navigation easily.

Performance and large-data strategies

react-data-grid supports virtualization—rendering only visible rows and columns—so UI remains snappy even with tens or hundreds of thousands of records. The key is to keep cells cheap: avoid inline functions in cell renderers and memoize heavy components.

For huge datasets, prefer server-side paging and server-side sorting/filtering. Send lightweight requests including sort and filter descriptors from the grid and return a page of rows. This keeps the client fast and reduces memory footprint.

Batch updates: collect multiple row edits in local state and send one update request instead of many small ones. Debounce autosave operations and use optimistic updates carefully to maintain a responsive UX.

Integration patterns: state, virtualization, and tooling

Controlled vs uncontrolled modes: controlled grids expect you to pass rows and handle onRowsChange; uncontrolled patterns keep internal state. Prefer controlled mode for predictable behavior, undo history, and integrations with Redux or React Query.

Combine the grid with virtualization libraries only if you need specialized behaviors; the built-in virtualization is usually sufficient. Use CSS containment and fixed row heights for smoother scrolling when possible. Avoid forcing re-renders of the grid container on every parent change.

Tooling: use TypeScript types shipped by the library for safer column definitions and editor props. Lint your cell components for performance patterns and profile with React DevTools when you suspect excessive re-renders.

Advanced topics: spreadsheet features, custom editors, and accessibility

To emulate a spreadsheet, implement custom editors that handle navigation keys and focus management. Support copy/paste by listening to clipboard events on focused cells and providing a plain-text/CSV representation that users expect.

Accessibility: ensure header cells have proper scope and ARIA attributes, and that editors have labels and keyboard focus control. The grid provides hooks for keyboard handling, but you must wire ARIA markup into custom components.

Custom cell types unlock domain-specific UX: currency formatting, conditional styling, progress bars, or interactive components. Keep formatters presentational and editors focused on input to preserve separation of concerns and performance.

Troubleshooting and best practices

If the grid looks blank, verify columns and rows are non-empty arrays and keys match. Console warnings are helpful—address prop-type or type mismatches first. Common pitfalls include uncontrolled inputs and missing row keys that cause row reordering bugs.

When editing seems to lag, audit render sources: memoize cell renderers, avoid new object references for unchanged props, and throttle heavy computations. Use requestAnimationFrame for expensive UI updates tied to scrolling.

Testing: use unit tests for custom editors and formatters and snapshot the grid configuration to catch regressions. For E2E tests, simulate keyboard navigation and cell edits to ensure real-world flows remain intact.

Example: editable, sortable grid with filtering (compact)

The snippet below shows a minimal pattern: columns with an editor, client-side filtering, and a controlled rows array. Replace filter logic with server calls for large datasets.

import React, { useState } from 'react';
import DataGrid from 'react-data-grid';

const columns = [
  { key: 'id', name: 'ID', width: 70 },
  { key: 'title', name: 'Title', editable: true },
  { key: 'count', name: 'Count', editable: true }
];

export default function MyGrid() {
  const [rows, setRows] = useState(initialRows);
  const [filter, setFilter] = useState('');

  const filtered = rows.filter(r => r.title.toLowerCase().includes(filter.toLowerCase()));

  return (
    <div>
      <input placeholder="Filter title" value={filter} onChange={e => setFilter(e.target.value)} />
      <DataGrid columns={columns} rows={filtered} onRowsChange={setRows} />
    </div>
  );
}

This pattern keeps your UI responsive for moderate datasets and provides clear hooks for swapping in server-side logic.

Backlinks and recommended resources

FAQ

How do I enable cell editing in react-data-grid?

Set editable: true on the column definition and handle onRowsChange to persist edits. For custom editors, pass an editor component to the column and implement focus/commit handlers according to the editor API.

Can react-data-grid handle millions of rows?

Yes—via virtualization and server-side paging. Keep the client-side window small and request pages (with sort/filter descriptors) from the server to avoid memory and rendering bottlenecks.

What’s the recommended way to implement filtering and sorting?

For small datasets, perform client-side filtering and sorting. For large or shared datasets, use the grid’s sort/filter descriptors to drive server-side queries and return paged results for the best performance.

Semantic core (keyword clusters)

Primary keywords:
- react-data-grid
- React Data Grid adazzle
- react-data-grid tutorial
- react-data-grid installation
- react-data-grid example
- react-data-grid setup
- react-data-grid editing
- react-data-grid sorting
- react-data-grid filtering
- react-data-grid library

Secondary keywords:
- React table component
- React data table
- React grid component
- React spreadsheet table
- react-data-grid example code
- interactive data table react
- react data grid performance
- virtualized react grid
- custom cell editor react-data-grid

Clarifying / intent-based queries (high/medium frequency):
- How to install react-data-grid (installation, npm)
- react-data-grid vs react-table (comparison)
- react-data-grid tutorial for beginners
- react-data-grid sorting and filtering example
- react-data-grid editing cell programmatically
- react-data-grid excel-like behavior (spreadsheet features)
- react-data-grid with TypeScript
- react-data-grid virtualization performance

LSI phrases and related formulations:
- virtualized rows
- column formatter
- onRowsChange callback
- controlled grid
- server-side paging
- custom editors and formatters
- keyboard navigation cells
- copy-paste support

Micro-markup (recommended)

Add this JSON-LD for FAQ to improve chances of featured snippets. Insert into the page head or before the closing body tag.

{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [
    {
      "@type": "Question",
      "name": "How do I enable cell editing in react-data-grid?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Set editable: true on the column definition and handle onRowsChange to persist edits. For custom editors, pass an editor component to the column and implement commit handlers."
      }
    },
    {
      "@type": "Question",
      "name": "Can react-data-grid handle millions of rows?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Yes — use virtualization and server-side paging. Request sorted/filtered pages from the backend and render only the visible slice to keep the UI responsive."
      }
    },
    {
      "@type": "Question",
      "name": "What’s the recommended way to implement filtering and sorting?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "For small datasets use client-side filtering and sorting; for large datasets use grid-provided descriptors to drive server-side queries with paging."
      }
    }
  ]
}

Author: Experienced React engineer — practical patterns for building interactive data tables with react-data-grid.


React Keen Slider: Performance, Setup & Customization





React Keen Slider: Performance, Setup & Customization


React Keen Slider: Performance, Setup & Customization

A pragmatic, code-forward guide to installing, integrating, and optimizing Keen Slider in modern React apps — with examples, hooks patterns, troubleshooting, and SEO-ready microdata.

Quick setup (install & initialize)

If you already know which React slider you want, installing Keen Slider is quick: add the package and the CSS, then mount the slider in a functional component. This short block shows the minimum viable setup to get a working touch carousel.

Use your package manager of choice and import the styles once (typically in index.js or App.js). The example below uses the official useKeenSlider hook from the Keen Slider React package; you can also instantiate imperative API with refs for more control.

npm install keen-slider react
# or
yarn add keen-slider react

/* In your component */
import 'keen-slider/keen-slider.min.css'
import { useKeenSlider } from 'keen-slider/react'

After installation, initialize the slider in a component, attach the returned ref to the container, and pass options. This pattern keeps the integration idiomatic to React and minimizes re-renders.

Getting started: a simple React example

Below is a compact but complete React component that demonstrates a practical setup: responsive slides, basic navigation, and a touch-ready configuration. It’s the typical starting point for production sliders and plays well with lazy-loaded images and server-rendered content.

import React from 'react'
import { useKeenSlider } from 'keen-slider/react'
import 'keen-slider/keen-slider.min.css'

export default function BasicCarousel() {
  const [sliderRef] = useKeenSlider({
    slidesPerView: 1.2,
    spacing: 12,
    mode: 'free',
  })

  return (
    <div ref={sliderRef} className="keen-slider">
      <div className="keen-slider__slide">Slide 1</div>
      <div className="keen-slider__slide">Slide 2</div>
      <div className="keen-slider__slide">Slide 3</div>
    </div>
  )
}

This example covers three core concerns: mounting the slider, applying styles, and controlling the behavior via options like slidesPerView and spacing. For advanced effects, refer to the official Keen Slider docs.

Core concepts & API you need to know

Keen Slider uses a compact API with options for mode (snap/free), loop, drag/touch behavior, breakpoints, and detailed event hooks. Learn the main knobs first — slidesPerView, spacing, mode, loop — and you can compose everything else (lazy loading, thumbnails, synchronized sliders) on top.

The React package exposes a hook (useKeenSlider) that returns a ref and methods when needed. The pattern keeps the slider instance off the render path, which helps with performance and predictable behavior in functional components.

Events like slideChanged and animationEnded let you wire analytics, custom pagination, and state-driven UI. If you prefer imperative control, you can capture the slider instance from the hook and drive it with .next(), .prev(), .moveToIdx(index), and other methods.

Performance: make the slider fast and responsive

Performance is the main reason teams pick Keen Slider for touch carousels. It relies on transforms, hardware-accelerated CSS, and a minimal runtime. To keep things snappy, prefer CSS transforms (translate3d) and avoid frequent layout-triggering style changes on slide elements.

For mobile, reduce paint cost by using will-change: transform on animated elements, compress large images, and lazy-load off-screen media. If you have dozens of slides, virtualize DOM nodes or render only nearby slides; this reduces memory spikes and keeps scrolling fluid.

Also, throttle expensive handlers and, where possible, use requestAnimationFrame for custom animations. Keen Slider batches its animation loop efficiently, but any work you attach to animation events should be lightweight.

Accessibility & UX considerations

Carousels often fail accessibility tests out of the box. Add clear controls (prev/next) with semantic buttons, keyboard support, and ARIA roles for region landmarks. Announce slide changes with an ARIA live region if auto-advancing or if the content is dynamic.

Make sure focusable elements inside slides are reachable with keyboard navigation. When a slide contains forms or interactive controls, avoid trapping focus; instead, provide skip links or pause autoplay. Users with assistive tech appreciate predictable, keyboardable controls.

Test on real devices and with screen readers. The difference between « works in a dev build » and « works for everyone » can be surprising, so bake accessibility checks into your QA process early.

Customization & advanced features

Keen Slider supports a lot: breakpoints for responsive behavior, custom easing, looped slides, synchronized carousels (thumbnails), and per-slide origin placement. Use breakpoints to change slidesPerView and spacing for small/large screens, keeping interactions natural across devices.

For visual flair, combine Keen Slider with CSS transitions or micro-interactions. If you need parallax, staggered animations, or slide-specific transforms, compute transforms in JS conservatively and let the GPU handle the paint. Avoid layout thrashing by reading DOM once and batching writes.

Custom navigation is straightforward: bind your buttons to the slider instance methods and update UI state from slideChanged events. For complex controls (range sliders, progress bars), compute the current progress from the instance’s details rather than relying on inner DOM width computations.

React integration patterns & hooks

There are two common patterns for using Keen Slider in React: the hook-based mount (useKeenSlider) and an imperative ref-based approach for advanced control. The hook is preferred for standard use; it returns a ref and optionally the instance and destroy methods.

When working with server-side rendering (SSR), avoid referencing window or document during initial render. Delay initialization to useEffect or conditionally render the slider only in the client. If you encounter hydration issues, ensure markup and classNames match between server and client.

For complex apps, consider creating a small wrapper hook that abstracts lazy-loading, responsive breakpoints, and event wiring. This keeps components simple and centralizes slider logic for maintainability and testing.

Common pitfalls & troubleshooting

Hydration mismatches are a frequent issue when sliders render differently on server vs client. Make sure slidesPerView and layout-affecting options are deterministic or initialized client-side in useEffect to avoid className differences.

Another common problem is invisible slides due to missing CSS. Remember to import ‘keen-slider/keen-slider.min.css’ or include the rules in your global stylesheet. Missing CSS is an easy-to-miss cause of layout breakage that’s also embarrassingly common.

If touch gestures feel blocked, check for pointer-events and touch-action CSS on parent containers. Heavy DOM nodes inside slides (complex lists, large images) can slow down gestures; defer non-essential content and use virtualization when necessary.

Examples & real-world patterns

Beyond the basic carousel, real projects use Keen Slider for product galleries with thumbnails, synchronized hero-and-nav sliders, and content carousels with selective autoplay. The library’s API makes synchronization simple: listen for slideChanged on one instance and call moveToIdx on another.

For product galleries, lazy-load images and prefetch adjacent slide images to balance perceived speed and bandwidth. Use thumbnails as navigation and highlight the active index for clear affordance.

If you want a deeper, practical walkthrough with advanced patterns, the developer-focused article on Dev.to provides concrete examples of touch sliders in React (see the linked walkthrough above).

SEO & microdata (suggested JSON-LD)

To help search engines and voice assistants understand your content, add structured data for the article and FAQ. This is especially useful if your page includes tutorial steps, FAQs, and clear how-to sections — which can trigger rich results.

Below are two recommended micro-markup snippets you can add to the page. Insert them in the document head or just before the closing <body> tag to provide FAQ and Article schema. Replace example fields with page-specific content and timestamps.

{
  "@context":"https://schema.org",
  "@type":"Article",
  "headline":"React Keen Slider: Performance, Setup & Customization",
  "author":{"@type":"Person","name":"Your Name"},
  "publisher":{"@type":"Organization","name":"Your Org"},
  "datePublished":"2026-03-09"
}
{
  "@context":"https://schema.org",
  "@type":"FAQPage",
  "mainEntity":[
    {"@type":"Question","name":"How do I install Keen Slider in React?","acceptedAnswer":{"@type":"Answer","text":"Install keen-slider, import its CSS, and use the useKeenSlider hook to attach a ref to your container."}},
    {"@type":"Question","name":"How do I optimize Keen Slider for mobile?","acceptedAnswer":{"@type":"Answer","text":"Use hardware-accelerated transforms, lazy-load images, virtualize many slides, and keep event handlers lightweight."}}
  ]
}

Troubleshooting checklist (short)

  • Import CSS: ensure keen-slider CSS is loaded.
  • SSR: initialize on client (useEffect) to avoid hydration issues.
  • Performance: lazy-load and virtualize if you have many slides.

FAQ

Q: How do I install and initialize Keen Slider in React?

A: Install the package (npm i keen-slider or yarn add keen-slider), import ‘keen-slider/keen-slider.min.css’, and use the useKeenSlider hook to attach a ref to your slider container. Initialize with options like slidesPerView, spacing, loop, and mode. For a full example, see the quick-start code block above or the official docs.

Q: How can I make Keen Slider performant on mobile?

A: Use CSS transforms (translate3d) for movement, lazy-load images, keep slide DOM shallow, and virtualize if you render many slides. Avoid heavy calculations on animation events and batch UI updates. Hardware acceleration and efficient image handling make the biggest difference.

Q: How do I customize navigation, pagination, or add thumbnails in React?

A: Use the slider instance methods (next, prev, moveToIdx) exposed by the hook. Wire buttons to these methods and update your UI on slideChanged events. For thumbnails, synchronize two slider instances: listen for changes in the main slider and call moveToIdx on the thumbnail slider (and vice versa for thumbnail clicks).


Expanded semantic core (grouped keywords)

Primary queries

  • keen-slider
  • React Keen Slider
  • keen-slider tutorial
  • keen-slider installation
  • keen-slider React integration

Secondary / intent-based queries

  • React touch slider
  • React carousel slider
  • React slider library
  • React performant slider
  • keen-slider setup
  • keen-slider example
  • keen-slider getting started

Clarifying / LSI phrases & synonyms

  • useKeenSlider hook
  • slider instance methods (next, prev, moveToIdx)
  • touch carousel React
  • hardware-accelerated slider
  • responsive slidesPerView
  • slider breakpoints, lazy-load images
  • carousel accessibility ARIA
  • virtualized slides

Search intent mapping (brief)

Mostly informational / commercial-intent for devs implementing a slider. Use-targeted content (installation, examples, performance) to match queries like « keen-slider tutorial » and « React touch slider ».

Recommended micro-markup to add

Add Article schema (for tutorial pages) and FAQ schema (for the question block above) to improve chances of a rich result. The JSON-LD snippets shown earlier are ready to adapt — include accurate published dates, author, and canonical URL to maximize trust.

Further reading and credits: Keen Slider official docs (keen-slider.io) and React documentation (reactjs.org). For an example-driven article, see the Dev.to walkthrough linked at the top.


Réflexions sur le fonctionnement d’un centre d’avortement

A l’occasion des débats récents concernant l’IVG en France, il m’est apparu intéressant de proposer ce document « historique » datant de 1974, écrit par Jean Furtos et moi-même, tous deux psychiatres pratiquant bénévolement des avortements clandestins. Il décrit les problématiques existantes dans les Centres où ils étaient réalisés afin de créer un état de fait avant la présentation de la loi Veil à l’Assemblée nationale.

L’article qui suit a été publié dans une revue de médecine, les «Cahiers Médicaux Lyonnais ». A noter que le Conseil de l’Ordre de l’époque avait informé les auteurs qu’il les condamnerait à une interdiction d’exercer la médecine pendant 10 ans si la loi ne passait pas…

Lire le document (pdf 3,1 Mo)

 

Le programme d’éducation à la sexualité nuisible au développement affectif de l’enfant

J’ai effectué l’exposé qui suit le 30-11-2023 devant le Conseil Supérieur des Programmes de l’Education nationale. Ses appels à la prudence n’ont pas été retenus. Avec le nouveau programme dévoilé en 2024, les parents n’ont pas leur mot à dire sur le contenu des séances. Ils sont « informés de l’esprit du programme », mais exclus de leur rôle essentiel: ajuster les réponses aux questions que pose leur enfant, au fur et à mesure de sa maturité.

Lire l’intervention (pdf)

© 2026 Dr. Maurice Berger

Theme by Anders NorénUp ↑