Skip to content

Commit daea03d

Browse files
committed
making set_props work with just a single component at a time
1 parent 1c8773a commit daea03d

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

dash/dash-renderer/src/utils/clientsideFunctions.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {updateProps, notifyObservers} from '../actions/index';
22
import {getPath} from '../actions/paths';
33

4-
const set_props = (updates: []) => {
4+
const set_props = (id: string | object, props: {[k: string]: any}) => {
55
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
// @ts-ignore
77
const ds = (window.dash_stores = window.dash_stores || []);
@@ -10,16 +10,14 @@ const set_props = (updates: []) => {
1010
const {paths} = getState();
1111
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1212
// @ts-ignore
13-
updates.forEach(({id, ...props}) => {
14-
const componentPath = getPath(paths, id);
15-
dispatch(
16-
updateProps({
17-
props,
18-
itempath: componentPath
19-
})
20-
);
21-
dispatch(notifyObservers({id, props}));
22-
});
13+
const componentPath = getPath(paths, id);
14+
dispatch(
15+
updateProps({
16+
props,
17+
itempath: componentPath
18+
})
19+
);
20+
dispatch(notifyObservers({id, props}));
2321
}
2422
};
2523

tests/integration/clientside/test_clientside_functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def test_sp001_clientside_setprops(dash_duo):
2626
app.clientside_callback(
2727
"""
2828
() => {
29-
window.dash_clientside.set_props("""
29+
"""
3030
+ json.dumps(ids)
31-
+ """)
31+
+ """.forEach(({id, ...props}) => window.dash_clientside.set_props(id, props))
3232
return window.dash_clientside.no_update
3333
}
3434
""",

0 commit comments

Comments
 (0)