MCPcopy Index your code
hub / github.com/plotly/dash / setProps

Function setProps

dash/dash-renderer/src/wrapper/DashWrapper.tsx:110–167  ·  view source on GitHub ↗
(newProps: UpdatePropsPayload)

Source from the content-addressed store, hash-verified

108 }, [_newRender]);
109
110 const setProps = (newProps: UpdatePropsPayload) => {
111 const {id} = renderComponentProps;
112 const {_dash_error, ...restProps} = newProps;
113
114 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
115 // @ts-ignore
116 dispatch((dispatch, getState) => {
117 const currentState = getState();
118 const {graphs} = currentState;
119 const oldLayout = getComponentLayout(
120 renderedPath.current,
121 currentState
122 );
123 if (!oldLayout) return;
124 const {props: oldProps} = oldLayout;
125 if (!oldProps) return;
126 const changedProps = pickBy(
127 (val, key) => !equals(val, oldProps[key]),
128 restProps
129 );
130 if (_dash_error) {
131 dispatch(
132 onError({
133 type: 'frontEnd',
134 error: _dash_error
135 })
136 );
137 }
138
139 if (isEmpty(changedProps)) {
140 return;
141 }
142
143 // Identify the modified props that are required for callbacks
144 const watchedKeys = getWatchedKeys(id, keys(changedProps), graphs);
145
146 batch(() => {
147 // Only dispatch changes to Dash if a watched prop changed
148 if (watchedKeys.length) {
149 dispatch(
150 notifyObservers({
151 id,
152 props: pick(watchedKeys, changedProps)
153 })
154 );
155 }
156
157 // Always update this component's props
158 dispatch(
159 updateProps({
160 props: changedProps,
161 itempath: renderedPath.current,
162 renderType: 'internal'
163 })
164 );
165 });
166 });
167 };

Callers 1

Calls 6

getComponentLayoutFunction · 0.90
getWatchedKeysFunction · 0.90
notifyObserversFunction · 0.90
updatePropsFunction · 0.90
getStateFunction · 0.85
isEmptyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…