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

Function set_props

dash/dash-renderer/src/utils/clientsideFunctions.ts:13–60  ·  view source on GitHub ↗

* Set the props of a dash component by id or path. * * @param idOrPath Path or id of the dash component to update. * @param props The props to update.

(
    idOrPath: string | object | string[],
    props: {[k: string]: any}
)

Source from the content-addressed store, hash-verified

11 * @param props The props to update.
12 */
13function set_props(
14 idOrPath: string | object | string[],
15 props: {[k: string]: any}
16) {
17 const ds = getStores();
18 for (let y = 0; y < ds.length; y++) {
19 const {dispatch, getState} = ds[y];
20 let componentPath;
21 const state = getState();
22 if (!Array.isArray(idOrPath)) {
23 componentPath = getPath(state.paths, idOrPath);
24 } else {
25 componentPath = idOrPath;
26 }
27 const oldComponent = getComponentLayout(componentPath, state);
28
29 // Handle any patch props
30 props = parsePatchProps(props, oldComponent?.props || {});
31
32 // Update the props
33 dispatch(
34 updateProps({
35 props,
36 itempath: componentPath,
37 renderType: 'clientsideApi'
38 })
39 );
40 dispatch(notifyObservers({id: idOrPath, props}));
41
42 if (!oldComponent) {
43 return;
44 }
45
46 dispatch(
47 setPaths(
48 computePaths(
49 {
50 ...oldComponent,
51 props: {...oldComponent.props, ...props}
52 },
53 [...componentPath],
54 state.paths,
55 state.paths.events
56 )
57 )
58 );
59 }
60}
61
62// Clean url code adapted from https://github.com/braintree/sanitize-url/blob/main/src/constants.ts
63// to allow for data protocol.

Callers

nothing calls this directly

Calls 8

getStoresFunction · 0.90
getPathFunction · 0.90
getComponentLayoutFunction · 0.90
parsePatchPropsFunction · 0.90
updatePropsFunction · 0.90
notifyObserversFunction · 0.90
computePathsFunction · 0.90
getStateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…