UNPKG

glass-app-manager

Version:

Informatica's Glass Framework CLI for bootstrapping

39 lines (37 loc) 1.07 kB
// import React from "react"; // import Main from "../containers/workspaces/Home/content/Main" // const DynamicComponent = (props) => { // const { name, ...rest } = props; // const WrappedComponent = name; // //import(path); // return ( // <WrappedComponent {...props}> // {props.children} // </WrappedComponent> // ) // } // import React, { Component } from 'react'; const DynamicComponent = (importedComponent) =>{ return class extends Component { constructor(props) { super(props); this.state = { module: null }; } componentDidMount() { importedComponent() .then((module) =>{ this.setState({ module: module.default }) }) } render() { const { module: Component } = this.state; // Assigning to new variable names @see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment return( <div> {Component && <Component/>} </div> ) } } } export default DynamicComponent;