Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance (datatable): avoiding unnecessary re-render of cells of rows with no state-change #7420

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

accioly-cassio
Copy link

@accioly-cassio accioly-cassio commented Nov 15, 2024

Defect Fixes

Fix #2979: Datatable performance improved by taking out parameters and functions of the BodyCells and placing in the BodyRow or TableBody components. Also, the set of BodyCell props to be checked when deciding for a re-render in React.memo was improved. This avoids now a lot of unnecessary re-render, including the issue from the linked issue.

Note that I also created a function called "selectiveCompare" in the BodyCell component to make the selection of which props should be checked at the React.memo. Maybe it makes sense to move it to the Utils, since it potentially can be used for optimizing the datatable further and more generally other library components. This selective comparison of the props is important since React.memo will not work as expected mainly if there are objects being parsed in the props.

Copy link

vercel bot commented Nov 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Updated (UTC)
primereact ⬜️ Ignored (Inspect) Visit Preview Nov 15, 2024 4:26pm
primereact-v9 ⬜️ Ignored (Inspect) Visit Preview Nov 15, 2024 4:26pm

@accioly-cassio
Copy link
Author

There might still be a bug when the metakey is used for column sorting. I'll verify this later today or tomorrow.

Copy link
Member

@melloware melloware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic just one recommendation

components/lib/datatable/BodyCell.js Outdated Show resolved Hide resolved
@melloware melloware added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Nov 15, 2024
…and getNestedValue from BodyCell.js to ObjectUtils and ran prettier to avoid pull request errors
@accioly-cassio accioly-cassio changed the title Dtable performance Performance (datatable): avoiding unnecessary re-render of cells of rows with no state-change Nov 17, 2024
@melloware melloware added the Type: Performance Issue is performance or optimization related label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team Type: Performance Issue is performance or optimization related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataTable: seems to re-render all the rows on select all, even with the pagination.
3 participants