const Form = React.lazy(() => import('./form/form')); | |
class App extends Component { | |
state = { | |
open: false, | |
} | |
handleClick = () => { | |
this.setState({ open: true }); | |
} | |
render() { | |
return ( | |
<Grid | |
container | |
className={styles.App} | |
direction="row" | |
justify="center" | |
alignItems="center" | |
> | |
< Button | |
onClick={ () => this.handleClick() } | |
variant="contained" | |
color="primary" | |
>Click Me</Button> | |
{ | |
this.state.open && ( | |
<Suspense fallback={<CircularProgress />}> | |
<Form/> | |
</Suspense> | |
) | |
} | |
</Grid> | |
); | |
} | |
} | |
export default App; |