Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- loader: () => import("../containers/HomeAContainer")
- import React, { Component } from 'react';
- const asyncComponent = ( importComponent ) => {
- return class extends Component{
- state = { component: null }
- componentDidMount(){
- importComponent().then(cmp =>{
- this.setState({component: cmp.default});
- });
- }
- render (){
- const C = this.state.component;
- return C ? <C {...this.props} /> : null;
- }
- }
- }
- export default asyncComponent;
- import Exemple from './example/example';
- Import asyncComponent from './asyncComponent';
- const asyncExample = asyncComponent(()=>{
- return import('./example/example');
- });
Add Comment
Please, Sign In to add comment