Skip to content

Commit cef0a60

Browse files
BSd3vKoolADE85
authored andcommitted
test of removal of default props
1 parent 4386b46 commit cef0a60

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed

src/lib/components/AgGrid.react.js

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import PropTypes from 'prop-types';
22
import LazyLoader from '../LazyLoader';
33
import React, {lazy, Suspense, useState, useCallback, useEffect} from 'react';
4+
import { pick } from 'ramda';
45

56
const RealAgGrid = lazy(LazyLoader.agGrid);
67
const RealAgGridEnterprise = lazy(LazyLoader.agGridEnterprise);
@@ -9,6 +10,25 @@ function getGrid(enable) {
910
return enable ? RealAgGridEnterprise : RealAgGrid;
1011
}
1112

13+
export const defaultProps = {
14+
className: 'ag-theme-alpine',
15+
resetColumnState: false,
16+
exportDataAsCsv: false,
17+
selectAll: false,
18+
deselectAll: false,
19+
enableEnterpriseModules: false,
20+
updateColumnState: false,
21+
persisted_props: ['selectedRows'],
22+
persistence_type: 'local',
23+
suppressDragLeaveHidesColumns: true,
24+
dangerously_allow_code: false,
25+
rowModelType: 'clientSide',
26+
dashGridOptions: {},
27+
filterModel: {},
28+
paginationGoTo: null,
29+
selectedRows: [],
30+
};
31+
1232
/**
1333
* Dash interface to AG Grid, a powerful tabular data component.
1434
*/
@@ -45,31 +65,23 @@ function DashAgGrid(props) {
4565

4666
return (
4767
<Suspense fallback={null}>
48-
<RealComponent parentState={state} {...props} />
68+
<RealComponent parentState={state} {...defaultProps} {...props} />
4969
</Suspense>
5070
);
5171
}
5272

73+
const REACT_VERSION_DASH2_COMPAT = 18.3;
74+
if (
75+
parseFloat(React.version.substring(0, React.version.lastIndexOf('.'))) <
76+
REACT_VERSION_DASH2_COMPAT
77+
) {
78+
DashAgGrid.defaultProps = defaultProps;
79+
} else {
80+
DashAgGrid.dashPersistence = pick(['persisted_props', 'persistence_type'],defaultProps);
81+
}
82+
5383
DashAgGrid.dashRenderType = true;
5484

55-
DashAgGrid.defaultProps = {
56-
className: 'ag-theme-alpine',
57-
resetColumnState: false,
58-
exportDataAsCsv: false,
59-
selectAll: false,
60-
deselectAll: false,
61-
enableEnterpriseModules: false,
62-
updateColumnState: false,
63-
persisted_props: ['selectedRows'],
64-
persistence_type: 'local',
65-
suppressDragLeaveHidesColumns: true,
66-
dangerously_allow_code: false,
67-
rowModelType: 'clientSide',
68-
dashGridOptions: {},
69-
filterModel: {},
70-
paginationGoTo: null,
71-
selectedRows: [],
72-
};
7385
DashAgGrid.propTypes = {
7486
/********************************
7587
* DASH PROPS
@@ -751,7 +763,6 @@ DashAgGrid.propTypes = {
751763
};
752764

753765
export const propTypes = DashAgGrid.propTypes;
754-
export const defaultProps = DashAgGrid.defaultProps;
755766

756767
export default DashAgGrid;
757768

src/lib/fragments/AgGrid.react.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,11 +1605,9 @@ export function DashAgGrid(props) {
16051605
);
16061606
}
16071607

1608-
DashAgGrid.defaultProps = _defaultProps;
16091608
DashAgGrid.propTypes = {parentState: PropTypes.any, ..._propTypes};
16101609

16111610
export const propTypes = DashAgGrid.propTypes;
1612-
export const defaultProps = DashAgGrid.defaultProps;
16131611

16141612
var dagfuncs = (window.dash_ag_grid = window.dash_ag_grid || {});
16151613
dagfuncs.useGridFilter = useGridFilter;

src/lib/utils/propCategories.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ export const PASSTHRU_PROPS = ['rowData'];
321321
*/
322322
export const PROPS_NOT_FOR_AG_GRID = [
323323
'children',
324+
'dashRenderType',
325+
'licenseKey',
324326
'setProps',
325327
'loading_state',
326328
'enableEnterpriseModules',
@@ -354,6 +356,7 @@ export const PROPS_NOT_FOR_AG_GRID = [
354356
'scrollTo',
355357
'eventListeners',
356358
'eventData',
359+
'paginationInfo',
357360
];
358361

359362
/**

0 commit comments

Comments
 (0)