Skip to content

Commit 35c9c78

Browse files
authored
Merge pull request #392 from BSd3v/remove-default-props
Remove Default Props
2 parents 6622d5f + 71d333c commit 35c9c78

File tree

3 files changed

+38
-27
lines changed

3 files changed

+38
-27
lines changed

src/lib/components/AgGrid.react.js

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
22
import LazyLoader from '../LazyLoader';
33
import React, {lazy, Suspense, useState, useCallback, useEffect} from 'react';
44
import {AllCommunityModule, ModuleRegistry} from 'ag-grid-community';
5+
import {pick} from 'ramda';
56

67
// Register all community features
78
ModuleRegistry.registerModules([AllCommunityModule]);
@@ -13,6 +14,25 @@ function getGrid(enable) {
1314
return enable ? RealAgGridEnterprise : RealAgGrid;
1415
}
1516

17+
export const defaultProps = {
18+
className: '',
19+
resetColumnState: false,
20+
exportDataAsCsv: false,
21+
selectAll: false,
22+
deselectAll: false,
23+
enableEnterpriseModules: false,
24+
updateColumnState: false,
25+
persisted_props: ['selectedRows'],
26+
persistence_type: 'local',
27+
suppressDragLeaveHidesColumns: true,
28+
dangerously_allow_code: false,
29+
rowModelType: 'clientSide',
30+
dashGridOptions: {},
31+
filterModel: {},
32+
paginationGoTo: null,
33+
selectedRows: [],
34+
};
35+
1636
/**
1737
* Dash interface to AG Grid, a powerful tabular data component.
1838
*/
@@ -49,31 +69,26 @@ function DashAgGrid(props) {
4969

5070
return (
5171
<Suspense fallback={null}>
52-
<RealComponent parentState={state} {...props} />
72+
<RealComponent parentState={state} {...defaultProps} {...props} />
5373
</Suspense>
5474
);
5575
}
5676

77+
const REACT_VERSION_DASH2_COMPAT = 18.3;
78+
if (
79+
parseFloat(React.version.substring(0, React.version.lastIndexOf('.'))) <
80+
REACT_VERSION_DASH2_COMPAT
81+
) {
82+
DashAgGrid.defaultProps = defaultProps;
83+
} else {
84+
DashAgGrid.dashPersistence = pick(
85+
['persisted_props', 'persistence_type'],
86+
defaultProps
87+
);
88+
}
89+
5790
DashAgGrid.dashRenderType = true;
5891

59-
DashAgGrid.defaultProps = {
60-
className: '',
61-
resetColumnState: false,
62-
exportDataAsCsv: false,
63-
selectAll: false,
64-
deselectAll: false,
65-
enableEnterpriseModules: false,
66-
updateColumnState: false,
67-
persisted_props: ['selectedRows'],
68-
persistence_type: 'local',
69-
suppressDragLeaveHidesColumns: true,
70-
dangerously_allow_code: false,
71-
rowModelType: 'clientSide',
72-
dashGridOptions: {},
73-
filterModel: {},
74-
paginationGoTo: null,
75-
selectedRows: [],
76-
};
7792
DashAgGrid.propTypes = {
7893
/********************************
7994
* DASH PROPS
@@ -755,7 +770,6 @@ DashAgGrid.propTypes = {
755770
};
756771

757772
export const propTypes = DashAgGrid.propTypes;
758-
export const defaultProps = DashAgGrid.defaultProps;
759773

760774
export default DashAgGrid;
761775

src/lib/fragments/AgGrid.react.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ import {
1515
assoc,
1616
assocPath,
1717
} from 'ramda';
18-
import {
19-
propTypes as _propTypes,
20-
defaultProps as _defaultProps,
21-
apiGetters,
22-
} from '../components/AgGrid.react';
18+
import {propTypes as _propTypes, apiGetters} from '../components/AgGrid.react';
2319
import {
2420
COLUMN_DANGEROUS_FUNCTIONS,
2521
COLUMN_MAYBE_FUNCTIONS,
@@ -1617,11 +1613,9 @@ export function DashAgGrid(props) {
16171613
);
16181614
}
16191615

1620-
DashAgGrid.defaultProps = _defaultProps;
16211616
DashAgGrid.propTypes = {parentState: PropTypes.any, ..._propTypes};
16221617

16231618
export const propTypes = DashAgGrid.propTypes;
1624-
export const defaultProps = DashAgGrid.defaultProps;
16251619

16261620
var dagfuncs = (window.dash_ag_grid = window.dash_ag_grid || {});
16271621
dagfuncs.useGridFilter = useGridFilter;

src/lib/utils/propCategories.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ export const PASSTHRU_PROPS = ['rowData'];
323323
*/
324324
export const PROPS_NOT_FOR_AG_GRID = [
325325
'children',
326+
'dashRenderType',
327+
'licenseKey',
326328
'setProps',
327329
'loading_state',
328330
'enableEnterpriseModules',
@@ -356,6 +358,7 @@ export const PROPS_NOT_FOR_AG_GRID = [
356358
'scrollTo',
357359
'eventListeners',
358360
'eventData',
361+
'paginationInfo',
359362
];
360363

361364
/**

0 commit comments

Comments
 (0)