Skip to content

Commit 2f0ab2d

Browse files
committed
refactored target_components prop
1 parent 840b322 commit 2f0ab2d

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

components/dash-core-components/src/components/Loading.react.js

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,25 @@ const Loading = ({
6262
if (!target_components) {
6363
return true;
6464
}
65-
const isMatchingComponent = target_components.some(component => {
66-
const [component_name, prop_name] = Object.entries(component)[0];
67-
return (
68-
loading_state.component_name === component_name &&
69-
loading_state.prop_name === prop_name
65+
const isMatchingComponent = () => {
66+
return Object.entries(target_components).some(
67+
([component_name, prop_names]) => {
68+
// Convert prop_names to an array if it's not already
69+
const prop_names_array = Array.isArray(prop_names)
70+
? prop_names
71+
: [prop_names];
72+
73+
return (
74+
loading_state.component_name === component_name &&
75+
(prop_names_array.includes('*') ||
76+
prop_names_array.some(
77+
prop_name =>
78+
loading_state.prop_name === prop_name
79+
))
80+
);
81+
}
7082
);
71-
});
83+
};
7284
return isMatchingComponent;
7385
};
7486

@@ -261,10 +273,15 @@ Loading.propTypes = {
261273

262274
/**
263275
* Specify component and prop to trigger showing the loading spinner
264-
* example: `[{"output-container": "children"}]`
276+
* example: `{"output-container": "children", "grid": ["rowData", "columnDefs]}`
265277
*
266278
*/
267-
target_components: PropTypes.arrayOf(PropTypes.object),
279+
target_components: PropTypes.objectOf(
280+
PropTypes.oneOfType([
281+
PropTypes.string,
282+
PropTypes.arrayOf(PropTypes.string),
283+
])
284+
),
268285

269286
/**
270287
* Component to use rather than the built-in spinner specified in the `type` prop.

0 commit comments

Comments
 (0)