-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
There was a problem hiding this 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.
src/hooks/useRowSelection.ts
Outdated
@@ -0,0 +1,12 @@ | |||
import { createContext, useContext } from 'react'; | |||
|
|||
export const RowSelectionContext = |
There was a problem hiding this comment.
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?
src/hooks/useRowSelectionChange.ts
Outdated
@@ -0,0 +1,12 @@ | |||
import { createContext, useContext } from 'react'; | |||
|
|||
export const RowSelectionChangeContext = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
Co-authored-by: Nicolas Stepien <[email protected]>
Co-authored-by: Nicolas Stepien <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Select all operation
Before
After