@@ -24,7 +24,7 @@ import {DashConfig} from '../config';
24
24
import { notifyObservers , onError , updateProps } from '../actions' ;
25
25
import { getWatchedKeys , stringifyId } from '../actions/dependencies' ;
26
26
import { recordUiEdit } from '../persistence' ;
27
- import { createElement , isDryComponent } from './wrapping' ;
27
+ import { createElement , getComponentLayout , isDryComponent } from './wrapping' ;
28
28
import Registry from '../registry' ;
29
29
import isSimpleComponent from '../isSimpleComponent' ;
30
30
import {
@@ -62,56 +62,61 @@ function DashWrapper({
62
62
const setProps = ( newProps : UpdatePropsPayload ) => {
63
63
const { id} = componentProps ;
64
64
const { _dash_error, ...restProps } = newProps ;
65
- const oldProps = componentProps ;
66
- const changedProps = pickBy (
67
- ( val , key ) => ! equals ( val , oldProps [ key ] ) ,
68
- restProps
69
- ) ;
70
- if ( _dash_error ) {
71
- dispatch (
72
- onError ( {
73
- type : 'frontEnd' ,
74
- error : _dash_error
75
- } )
65
+
66
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
67
+ // @ts -ignore
68
+ dispatch ( ( dispatch , getState ) => {
69
+ const currentState = getState ( ) ;
70
+ const { graphs} = currentState ;
71
+
72
+ const { props : oldProps } = getComponentLayout (
73
+ componentPath ,
74
+ currentState
76
75
) ;
77
- }
78
- if ( ! isEmpty ( changedProps ) ) {
79
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
80
- // @ts -ignore
81
- dispatch ( ( dispatch , getState ) => {
82
- const { graphs} = getState ( ) ;
83
- // Identify the modified props that are required for callbacks
84
- const watchedKeys = getWatchedKeys (
85
- id ,
86
- keys ( changedProps ) ,
87
- graphs
76
+ const changedProps = pickBy (
77
+ ( val , key ) => ! equals ( val , oldProps [ key ] ) ,
78
+ restProps
79
+ ) ;
80
+ if ( _dash_error ) {
81
+ dispatch (
82
+ onError ( {
83
+ type : 'frontEnd' ,
84
+ error : _dash_error
85
+ } )
88
86
) ;
87
+ }
89
88
90
- batch ( ( ) => {
91
- // setProps here is triggered by the UI - record these changes
92
- // for persistence
93
- recordUiEdit ( component , newProps , dispatch ) ;
89
+ if ( isEmpty ( changedProps ) ) {
90
+ return ;
91
+ }
94
92
95
- // Only dispatch changes to Dash if a watched prop changed
96
- if ( watchedKeys . length ) {
97
- dispatch (
98
- notifyObservers ( {
99
- id,
100
- props : pick ( watchedKeys , changedProps )
101
- } )
102
- ) ;
103
- }
93
+ // Identify the modified props that are required for callbacks
94
+ const watchedKeys = getWatchedKeys ( id , keys ( changedProps ) , graphs ) ;
95
+
96
+ batch ( ( ) => {
97
+ // setProps here is triggered by the UI - record these changes
98
+ // for persistence
99
+ recordUiEdit ( component , newProps , dispatch ) ;
104
100
105
- // Always update this component's props
101
+ // Only dispatch changes to Dash if a watched prop changed
102
+ if ( watchedKeys . length ) {
106
103
dispatch (
107
- updateProps ( {
108
- props : changedProps ,
109
- itempath : componentPath
104
+ notifyObservers ( {
105
+ id ,
106
+ props : pick ( watchedKeys , changedProps )
110
107
} )
111
108
) ;
112
- } ) ;
109
+ }
110
+
111
+ // Always update this component's props
112
+ dispatch (
113
+ updateProps ( {
114
+ props : changedProps ,
115
+ itempath : componentPath
116
+ } )
117
+ ) ;
113
118
} ) ;
114
- }
119
+ } ) ;
115
120
} ;
116
121
117
122
const createContainer = useCallback (
0 commit comments