Open CosticaPuntaru opened 6 years ago
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>
)
}
}
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)