Skip to content

Commit 1f56612

Browse files
committed
useLoading in html components
1 parent 1a56d4f commit 1f56612

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

components/dash-html-components/scripts/generate-components.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -176,24 +176,6 @@ function generatePropTypes(element, attributes) {
176176
'${attributeName}': PropTypes.${propType},`;
177177
}, '') + `
178178
179-
/**
180-
* Object that holds the loading state object coming from dash-renderer
181-
*/
182-
'loading_state': PropTypes.shape({
183-
/**
184-
* Determines if the component is loading or not
185-
*/
186-
is_loading: PropTypes.bool,
187-
/**
188-
* Holds which property is loading
189-
*/
190-
prop_name: PropTypes.string,
191-
/**
192-
* Holds the name of the component that is loading
193-
*/
194-
component_name: PropTypes.string,
195-
}),
196-
197179
/**
198180
* Dash-assigned callback that gets fired when the element is clicked.
199181
*/
@@ -300,7 +282,9 @@ ${customImport}
300282
*/
301283
const ${Component} = ({n_clicks = 0, n_clicks_timestamp = -1, ...props}) => {
302284
const extraProps = {};
303-
if(props.loading_state && props.loading_state.is_loading) {
285+
const ctx = window.dash_component_api.useDashContext();
286+
const loading = ctx.useLoading();
287+
if (loading) {
304288
extraProps['data-dash-is-loading'] = true;
305289
}
306290
${customCode}

0 commit comments

Comments
 (0)