asyncBootstrap is not called when using create-react-app
burrack opened this issue · 2 comments
burrack commented
Hi,
I tried to follow the example in the docs and for some reason the asyncBootstrap function is not called inside Product.
i'm using create-react-app.
Did it happen to you maybe ?
bguiz commented
same happening here.
in src/index.js:
asyncBootstrapper(App).then(() => {
reactSnapshotRender(<App />, document.getElementById('root'));
registerServiceWorker();
});
in src/Page.js
class Page extends Component {
asyncBootstrap() {
console.log('Page.asyncBootstrap');
}
The console.log statement never gets printed.
The hierarchy is:
App -> Router -> div -> Switch -> Route -> Page
(using create-react-app with:
"react": "^15.6.1",
"react-async-bootstrapper": "^1.1.1",
"react-router-dom": "^4.1.1",
)
SleepWalker commented
@bguiz here is your mistake:
reactSnapshotRender(, document.getElementById('root'));
You have bootstrapped some App and then rendered the completely fresh new <App /> instead.
it should be:
const App = <App />;
asyncBootstrapper(App).then(() => {
reactSnapshotRender(App, document.getElementById('root'));
registerServiceWorker();
});