@@ -6,7 +6,7 @@ import Message from '../../components/Message'
66
77interface Props {
88text :string
9- context :T . MachineContext
9+ context ? :T . MachineContext
1010}
1111
1212const styles = {
@@ -16,19 +16,36 @@ const styles = {
1616flexDirection :'column' as 'column' ,
1717alignItems :'center' ,
1818justifyContent :'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 ) {
2637return (
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+
3249return (
3350< div css = { styles . page } >
3451< Loading text = { text } />