File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed
web-app/src/containers/Loading Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import Message from '../../components/Message'
66
77interface Props {
88 text : string
9- context : T . MachineContext
9+ context ? : T . MachineContext
1010}
1111
1212const styles = {
@@ -16,19 +16,36 @@ const styles = {
1616 flexDirection : 'column' as 'column' ,
1717 alignItems : 'center' ,
1818 justifyContent : 'center' ,
19- width : '100%' ,
19+ height : '100%' ,
2020 } ,
2121}
2222
2323const LoadingPage = ( { text, context } : Props ) => {
24- const { error } = context
25- if ( error ) {
24+ const [ showLoading , setShowHiding ] = React . useState ( false )
25+
26+ React . useEffect ( ( ) => {
27+ // wait some time before showing loading indicator
28+ const timeout = setTimeout ( ( ) => {
29+ setShowHiding ( true )
30+ } , 600 )
31+ return ( ) => {
32+ clearTimeout ( timeout )
33+ }
34+ } , [ ] )
35+
36+ if ( context && context . error ) {
2637 return (
2738 < div css = { styles . page } >
28- < Message type = "error" title = { error . title } content = { error . description } />
39+ < Message type = "error" title = { context . error . title } content = { context . error . description } />
2940 </ div >
3041 )
3142 }
43+
44+ // don't flash loader
45+ if ( ! showLoading ) {
46+ return null
47+ }
48+
3249 return (
3350 < div css = { styles . page } >
3451 < Loading text = { text } />
You can’t perform that action at this time.
0 commit comments