Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- class App extends Component {
- state = {
- AsyncComponent: () => <div>Nothing loaded</div>,
- };
- async componentDidMount() {
- const module = await import('./AsyncComponent');
- const AsyncComponent = module.default;
- this.setState({ AsyncComponent });
- }
- render() {
- const { AsyncComponent } = this.state;
- return <AsyncComponent />;
- }
- }
- export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement