react-async-bootstrapper icon indicating copy to clipboard operation
react-async-bootstrapper copied to clipboard

example with react-router-dom

Open CosticaPuntaru opened this issue 7 years ago • 1 comments

As react router dom is the most used router for react. it will be nice to have an example of integrating the router with the bootstrapper to make sure the bootstrap function is called on route change (somehow)

CosticaPuntaru avatar Aug 28 '18 15:08 CosticaPuntaru

a good enough solution is:


class DirectComponent extends Component {
    bootstrap() {
        console.log('direct bootstrap was called', this);
        return new Promise((resolve) => {
            setTimeout(() => {
                resolve(1)
            }, 2000)
        })
    }

    componentDidMount() {
        console.log('component did mount');
        this.bootstrap();
    }

    render() {
        console.log('render called');
        return (
            <div>
                my component
            </div>
        )
    }
}

CosticaPuntaru avatar Aug 29 '18 07:08 CosticaPuntaru