@@ -23,6 +23,7 @@ const getSpinner = spinnerType =>
23
23
const Loading = ( {
24
24
children,
25
25
loading_state,
26
+ mode,
26
27
color,
27
28
className,
28
29
style,
@@ -77,6 +78,11 @@ const Loading = ({
77
78
78
79
// delay_hide and delay_show is from dash-bootstrap-components dbc.Spinner
79
80
useEffect ( ( ) => {
81
+ if ( mode === 'on' || mode === 'off' ) {
82
+ setShowSpinner ( mode === 'on' ) ;
83
+ return ;
84
+ }
85
+
80
86
if ( loading_state ) {
81
87
if ( loading_state . is_loading ) {
82
88
// if component is currently loading and there's a dismiss timer active
@@ -108,7 +114,7 @@ const Loading = ({
108
114
}
109
115
}
110
116
}
111
- } , [ delay_hide , delay_show , loading_state ] ) ;
117
+ } , [ delay_hide , delay_show , loading_state , mode ] ) ;
112
118
113
119
const Spinner = showSpinner && getSpinner ( spinnerType ) ;
114
120
@@ -147,6 +153,7 @@ Loading.defaultProps = {
147
153
delay_show : 0 ,
148
154
delay_hide : 0 ,
149
155
show_initially : true ,
156
+ mode : 'auto' ,
150
157
} ;
151
158
152
159
Loading . propTypes = {
@@ -230,6 +237,11 @@ Loading.propTypes = {
230
237
component_name : PropTypes . string ,
231
238
} ) ,
232
239
240
+ /**
241
+ * Setting mode to "on" or "off" will override the loading state coming from dash-renderer
242
+ */
243
+ mode : PropTypes . oneOf ( [ 'auto' , 'on' , 'off' ] ) ,
244
+
233
245
/**
234
246
* Add a time delay (in ms) to the spinner being removed to prevent flickering.
235
247
*/
0 commit comments