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

[DataGrid] Use new selectors #15200

Merged
merged 14 commits into from
Dec 11, 2024
Merged

Conversation

MBilalShafi
Copy link
Member

@MBilalShafi MBilalShafi commented Oct 30, 2024

Closes #15478

Todos

  • Fix tests
  • Add BCs to migration guide

Follow-ups:

  • Codemod
  • Convert selector creator methods to selectors with arguments

Changelog

Breaking changes

  • The selectors signature has been updated due to the support of arguments in the selectors. Pass undefined as arguments if the selector doesn't use any arguments.

    -mySelector(state, instanceId)
    +mySelector(state, arguments, instanceId)
  • The useGridSelector signature has been updated due to the introduction of arguments parameter in the selectors. Pass undefined as arguments if the selector doesn't use any arguments.

    -const output = useGridSelector(apiRef, selector, equals)
    +const output = useGridSelector(apiRef, selector, arguments, equals)

@MBilalShafi MBilalShafi added core Infrastructure work going on behind the scenes component: data grid This is the name of the generic UI component, not the React module! labels Oct 30, 2024
@mui-bot
Copy link

mui-bot commented Oct 30, 2024

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 8, 2024
Copy link

github-actions bot commented Nov 8, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 13, 2024
@MBilalShafi MBilalShafi changed the title [DataGrid] Improve v8 selectors [DataGrid] Replace v7 selectors with v8 Nov 13, 2024
@MBilalShafi MBilalShafi changed the title [DataGrid] Replace v7 selectors with v8 [DataGrid] Use new selectors Nov 28, 2024
(
apiRef: React.MutableRefObject<{ state: State; instanceId: GridCoreApi['instanceId'] }>,
args?: Args,
): Result;
(state: State, instanceId: GridCoreApi['instanceId']): Result;
(state: State, args?: Args, instanceId?: GridCoreApi['instanceId']): Result;
Copy link
Member Author

@MBilalShafi MBilalShafi Dec 7, 2024

Choose a reason for hiding this comment

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

Instance ID parameter being required feels unnecessary.

  1. We allow slicing data without passing it, it could be fine if the user is aware of the performance issues a respective selector may cause.
  2. It doesn't apply to non-memoized selectors.
  3. Even for the memoized selectors, we warn the users to beware of the possible performance issues and act accordingly.

With #11440 it would even be more relevant as the only officially supported way would be the selector(apiRef). Comments are welcome.

Copy link
Contributor

Choose a reason for hiding this comment

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

As long as we do #11440, we can get rid of those for v8.

cellParams1.api.state,
cellParams1.api.instanceId,
);
const model = gridRowGroupingSanitizedModelSelector({ current: cellParams1.api });
Copy link
Member Author

Choose a reason for hiding this comment

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

A step towards #11440

Copy link
Contributor

Choose a reason for hiding this comment

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

We're passing api in a few places, we should probably consider replacing those with apiRef.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it couples more with #11440, let's consider it when working on that.

@MBilalShafi MBilalShafi self-assigned this Dec 7, 2024
@MBilalShafi MBilalShafi marked this pull request as ready for review December 7, 2024 07:02
@MBilalShafi MBilalShafi requested a review from a team December 7, 2024 07:02
@MBilalShafi MBilalShafi enabled auto-merge (squash) December 11, 2024 10:16
@MBilalShafi MBilalShafi merged commit e7a9530 into mui:master Dec 11, 2024
16 checks passed
@MBilalShafi MBilalShafi deleted the update-selectors branch December 11, 2024 10:33
lauri865 pushed a commit to lauri865/mui-x that referenced this pull request Dec 19, 2024
LukasTy pushed a commit to LukasTy/mui-x that referenced this pull request Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: data grid This is the name of the generic UI component, not the React module! core Infrastructure work going on behind the scenes v8.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] Use new selectors
3 participants