1
- import React , { useMemo , useCallback } from 'react' ;
1
+ import React , { useMemo , useCallback , memo } from 'react' ;
2
2
import {
3
3
path ,
4
4
concat ,
@@ -29,8 +29,6 @@ import isSimpleComponent from '../isSimpleComponent';
29
29
import {
30
30
selectDashProps ,
31
31
selectDashPropsEqualityFn ,
32
- selectLoadingState ,
33
- selectLoadingStateEqualityFn ,
34
32
selectConfig
35
33
} from './selectors' ;
36
34
import CheckedComponent from './CheckedComponent' ;
@@ -51,17 +49,11 @@ function DashWrapper({
51
49
const config : DashConfig = useSelector ( selectConfig ) ;
52
50
53
51
// Select both the component and it's props.
54
- const [ component , componentProps ] = useSelector (
52
+ const [ component , componentProps , loading_state ] = useSelector (
55
53
selectDashProps ( componentPath ) ,
56
54
selectDashPropsEqualityFn
57
55
) ;
58
56
59
- // Loading state for dcc.Loading
60
- const loading_state = useSelector (
61
- selectLoadingState ( componentPath ) ,
62
- selectLoadingStateEqualityFn
63
- ) ;
64
-
65
57
const setProps = ( newProps : UpdatePropsPayload ) => {
66
58
const { id} = componentProps ;
67
59
const { _dash_error, ...restProps } = newProps ;
@@ -172,7 +164,8 @@ function DashWrapper({
172
164
173
165
const extraProps = {
174
166
loading_state,
175
- setProps
167
+ setProps,
168
+ _dashprivate_layout : component
176
169
} ;
177
170
178
171
const element = useMemo ( ( ) => Registry . resolve ( component ) , [ component ] ) ;
@@ -422,4 +415,10 @@ function DashWrapper({
422
415
) ;
423
416
}
424
417
425
- export default DashWrapper ;
418
+ export default memo (
419
+ DashWrapper ,
420
+ ( prevProps , nextProps ) =>
421
+ JSON . stringify ( prevProps . _dashprivate_path ) ===
422
+ JSON . stringify ( nextProps . _dashprivate_path ) &&
423
+ prevProps . _dashprivate_error === nextProps . _dashprivate_error
424
+ ) ;
0 commit comments