Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. import React, { Component } from 'react';
  2.  
  3. class App extends Component {
  4. state = {
  5. AsyncComponent: () => <div>Nothing loaded</div>,
  6. };
  7.  
  8. async componentDidMount() {
  9. const module = await import('./AsyncComponent');
  10. const AsyncComponent = module.default;
  11.  
  12. this.setState({ AsyncComponent });
  13. }
  14.  
  15. render() {
  16. const { AsyncComponent } = this.state;
  17.  
  18. return <AsyncComponent />;
  19. }
  20. }
  21.  
  22. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement