ant-design/ant-design

All checkboxes are re-rendered in each render in a table with rowSelection enabled

Ouverte

#29 543 ouverte le 28 févr. 2021

 (5 commentaires) (1 réaction) (0 personne assignée)TypeScript (54 612 forks)batch import
Inactivehelp wanted

Métriques du dépôt

Stars
 (98 031 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  • open the codesandbox demo in a new window
  • open the react dev tools profiler tab, check Record why each component rendered while profiling.
  • start the react dev tools profiling
  • check one record in the demo table
  • stop the react dev tools profiling
  • in the flamegraph, one can see every single checkbox is re-rendered with reasons saying: "Props changed: (onClick, onChange)"

What is expected?

Only the relative checkbox should be re-rendered.

What is actually happening?

All checkboxes are re-rendered.

Environment Info
antd 4.12.3
React 17.0.1
System Windows 10 Pro 20H2 19042.804
Browser Microsoft Edge 88.0.705.74

There will be a noticeable UI lagging when there are hundreds of records in a table. onClick and onChange shouldn't be updated in each render.

Guide contributeur