Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to check that the component has loaded? #213

Open
joetidee opened this issue Jun 16, 2020 · 0 comments
Open

How to check that the component has loaded? #213

joetidee opened this issue Jun 16, 2020 · 0 comments

Comments

@joetidee
Copy link

joetidee commented Jun 16, 2020

What is the best way to detect that the DoThis has loaded?

const DoThis = universal(import(/* webpackChunkName: 'do-this' */ 'src/do-this.js'));

class DoThisLoader extends React.Component {
    constructor() {
        super();
        this.state = {
            dataLoaded: false,
        };
    }    

    componentWillMount() {
        DoThis.preload();
    }

    componentDidMount() {
        loadSomeData().then(() => this.setState({ dataLoaded: true }));
    }

    render() {
        return dataLoaded && DoThis ? <DoThis /> : <DoThat />;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant