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

Use context for selection #2338

Merged
merged 15 commits into from
May 13, 2021
Merged

Use context for selection #2338

merged 15 commits into from
May 13, 2021

Conversation

amanmahajan7
Copy link
Contributor

Select all operation
Before
image
image

After
image
image

Copy link
Contributor

@nstepien nstepien left a comment

Choose a reason for hiding this comment

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

Can't we just render the providers in DataGrid once?
That way we can avoid Row re-renders perhaps.
We might trigger formatter re-renders more often, but it's probably still less heavy since it's only for the few formatters that are in the viewport, and are using the contexts.
Row selection values won't change often anyway.

@@ -0,0 +1,12 @@
import { createContext, useContext } from 'react';

export const RowSelectionContext =
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's export the Provider directly here instead, that way we save a property access during render.

Also can we merge the two contexts into one?

@@ -0,0 +1,12 @@
import { createContext, useContext } from 'react';

export const RowSelectionChangeContext =
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

src/Row.tsx Outdated Show resolved Hide resolved
@amanmahajan7
Copy link
Contributor Author

Before
image

After
image

This profile is for selecting/deselecting all rows.

@amanmahajan7 amanmahajan7 self-assigned this May 13, 2021
@amanmahajan7 amanmahajan7 marked this pull request as ready for review May 13, 2021 16:00
src/hooks/useRowSelection.ts Outdated Show resolved Hide resolved
src/hooks/useRowSelection.ts Outdated Show resolved Hide resolved
src/Row.tsx Outdated Show resolved Hide resolved
amanmahajan7 and others added 3 commits May 13, 2021 11:45
nstepien
nstepien previously approved these changes May 13, 2021
src/hooks/useRowSelection.ts Outdated Show resolved Hide resolved
Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com>
Copy link
Contributor

@nstepien nstepien left a comment

Choose a reason for hiding this comment

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

:shipit:

@amanmahajan7 amanmahajan7 merged commit efc361e into canary May 13, 2021
@amanmahajan7 amanmahajan7 deleted the am-context branch May 13, 2021 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants