-
-
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
base: master
Are you sure you want to change the base?
Changes from 4 commits
d1f207d
dd6b9bf
5fce878
1a15179
42a3a1f
5d76140
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { createSelector } from '@mui/x-data-grid-pro/internals'; | ||
import { GridStatePremium } from '../../../models/gridStatePremium'; | ||
import { GridApiPremium } from '../../../models/gridApiPremium'; | ||
|
||
export const gridAggregationStateSelector = (state: GridStatePremium) => state.aggregation; | ||
export const gridAggregationStateSelector = (apiRef: React.RefObject<GridApiPremium>) => | ||
apiRef.current.state.aggregation; | ||
Comment on lines
-4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if creating a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Creating a type like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was about to do that, but have to resolve rendering issues first 🙂 |
||
|
||
/** | ||
* Get the aggregation model, containing the aggregation function of each column. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { GridStatePremium } from '../../../models/gridStatePremium'; | ||
import { GridApiPremium } from '../../../models/gridApiPremium'; | ||
|
||
export const gridCellSelectionStateSelector = (state: GridStatePremium) => state.cellSelection; | ||
export const gridCellSelectionStateSelector = (apiRef: React.RefObject<GridApiPremium>) => | ||
apiRef.current.state.cellSelection; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ export const useGridColumnPinning = ( | |
|
||
const stateExportPreProcessing = React.useCallback<GridPipeProcessor<'exportState'>>( | ||
(prevState, context) => { | ||
const pinnedColumnsToExport = gridPinnedColumnsSelector(apiRef.current.state); | ||
const pinnedColumnsToExport = gridPinnedColumnsSelector(apiRef); | ||
|
||
const shouldExportPinnedColumns = | ||
// Always export if the `exportOnlyDirtyModels` property is not activated | ||
|
@@ -227,7 +227,7 @@ export const useGridColumnPinning = ( | |
); | ||
|
||
const getPinnedColumns = React.useCallback<GridColumnPinningApi['getPinnedColumns']>(() => { | ||
return gridPinnedColumnsSelector(apiRef.current.state); | ||
return gridPinnedColumnsSelector(apiRef); | ||
}, [apiRef]); | ||
Comment on lines
229
to
231
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should deprecate API methods that only call a selector. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes please 👍🏻 |
||
|
||
const setPinnedColumns = React.useCallback<GridColumnPinningApi['setPinnedColumns']>( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { GridStateCommunity } from '../../models/gridStateCommunity'; | ||
import { GridApiCommunity } from '../../models/api/gridApiCommunity'; | ||
|
||
/** | ||
* Get the theme state | ||
* @category Core | ||
*/ | ||
export const gridIsRtlSelector = (state: GridStateCommunity) => state.isRtl; | ||
export const gridIsRtlSelector = (apiRef: React.RefObject<GridApiCommunity>) => | ||
apiRef.current.state.isRtl; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { GridStateCommunity } from '../../../models/gridStateCommunity'; | ||
import { GridApiCommunity } from '../../../models/api/gridApiCommunity'; | ||
|
||
export const gridColumnMenuSelector = (state: GridStateCommunity) => state.columnMenu; | ||
export const gridColumnMenuSelector = (apiRef: React.RefObject<GridApiCommunity>) => | ||
apiRef.current.state.columnMenu; |
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.
These should probably be selectors with arguments.
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.
And
rowSelector
below as well.