-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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] All selectors accept only apiRef
as first argument
#16198
Conversation
packages/x-data-grid-pro/src/components/GridDataSourceTreeDataGroupingCell.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/components/GridDataSourceGroupingCriteriaCell.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/hooks/features/aggregation/gridAggregationSelectors.ts
Outdated
Show resolved
Hide resolved
packages/x-data-grid-pro/src/hooks/features/columnPinning/useGridColumnPinning.tsx
Show resolved
Hide resolved
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
5d76140
to
0d0bb29
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
4f7a4b4
to
b126037
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
b126037
to
e854e1a
Compare
37c069b
to
af9e890
Compare
3df7ba0
to
e597e63
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
0c8ba5c
to
fde84ea
Compare
05a937a
to
8d9bade
Compare
); | ||
``` | ||
|
||
To make the developer experience better, selectors are typed to allow `apiRef` to reference a `null` value, but they throw an error if called before the state is initialized. Use selectors after the initialization in a `useEffect()` hook or in an event handler. |
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.
I did this to allow using selectors with the apiRef
retrieved from useGridApiRef()
. It opens the room for an error, but I think it is still better than casting apiRef
any time you need to pass it to the selector.
…f retrieved from the hook
335d1ea
to
eaff51d
Compare
@@ -12,23 +11,19 @@ const reselectCreateSelector = createSelectorCreator({ | |||
maxSize: 1, | |||
equalityCheck: Object.is, | |||
}, | |||
argsMemoize: customWeakMapMemoize, |
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.
Why did we need to add a custom implementation?
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.
@MBilalShafi actually fixed this
reselect
version didn't catch the updates inside apiRef
of the dependency selectors, so the return values would be inaccurate
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.
The original function weakMapMemoize
doesn't memoize the apiRef
argument properly due to the static nature of refs, causing in reselect wrapped selectors to not work properly, the custom implementation causes to use apiRef.current.state
for comparison rather than apiRef
itself.
Closes #11440
Changelog
Breaking changes
The selectors signature has been updated. They are only accepting
apiRef
as a first argument.