11import PropTypes from 'prop-types' ;
22import LazyLoader from '../LazyLoader' ;
33import React , { lazy , Suspense , useState , useCallback , useEffect } from 'react' ;
4+ import { pick } from 'ramda' ;
45
56const RealAgGrid = lazy ( LazyLoader . agGrid ) ;
67const 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+
5383DashAgGrid . 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- } ;
7385DashAgGrid . propTypes = {
7486 /********************************
7587 * DASH PROPS
@@ -751,7 +763,6 @@ DashAgGrid.propTypes = {
751763} ;
752764
753765export const propTypes = DashAgGrid . propTypes ;
754- export const defaultProps = DashAgGrid . defaultProps ;
755766
756767export default DashAgGrid ;
757768
0 commit comments