File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed
Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change 33import { AppLayout } from '@/components/AppLayout' ;
44import { SkillFormGithub } from '@/components/Contribute/Skill/Github/index' ;
55import { SkillFormNative } from '@/components/Contribute/Skill/Native/index' ;
6+ import { t_global_spacer_xl as XlSpacerSize } from '@patternfly/react-tokens' ;
7+ import { Flex , Spinner } from '@patternfly/react-core' ;
68import { useEffect , useState } from 'react' ;
79
810const SkillFormPage : React . FunctionComponent = ( ) => {
911 const [ deploymentType , setDeploymentType ] = useState < string | undefined > ( ) ;
12+ const [ loaded , setLoaded ] = useState < boolean > ( ) ;
1013
1114 useEffect ( ( ) => {
15+ let canceled = false ;
16+
1217 const getEnvVariables = async ( ) => {
1318 const res = await fetch ( '/api/envConfig' ) ;
1419 const envConfig = await res . json ( ) ;
15- setDeploymentType ( envConfig . DEPLOYMENT_TYPE ) ;
20+ if ( ! canceled ) {
21+ setDeploymentType ( envConfig . DEPLOYMENT_TYPE ) ;
22+ setLoaded ( true ) ;
23+ }
1624 } ;
25+
1726 getEnvVariables ( ) ;
18- } , [ ] ) ;
1927
20- return < AppLayout className = "contribute-page" > { deploymentType === 'native' ? < SkillFormNative /> : < SkillFormGithub /> } </ AppLayout > ;
28+ return ( ) => {
29+ canceled = true ;
30+ } ;
31+ } , [ ] ) ;
32+ return (
33+ < AppLayout className = "contribute-page" >
34+ { loaded ? (
35+ < > { deploymentType === 'native' ? < SkillFormNative /> : < SkillFormGithub /> } </ >
36+ ) : (
37+ < Flex alignItems = { { default : 'alignItemsCenter' } } justifyContent = { { default : 'justifyContentCenter' } } style = { { padding : XlSpacerSize . var } } >
38+ < Spinner size = "xl" />
39+ </ Flex >
40+ ) }
41+ </ AppLayout >
42+ ) ;
2143} ;
2244
2345export default SkillFormPage ;
You can’t perform that action at this time.
0 commit comments