Open jdelafon opened 8 years ago
I checked that it also is the case with the startup code, just adding this to /pages/home/index.js:
constructor() {
super();
console.debug("RECONSTRUCT HOMEPAGE!");
}
I'm going to try react-router to see if it does the same.
With react-router everything is fine: my components are not completely reset on each route change. There must be a serious issue with the current custom router in this project.
Edit: I had to remove HMR for it to work right away, so maybe this problem is due to HMR? Btw it is a real pain to reconfigure HMR to work again, which kills the purpose of using boilerplate code.
Edit2: 100% HMR is the reason for this, probably because this project does not use react-hot-loader, but vanilla Webpack HMR API, and for some reason it gets triggered on route change. React-router got a react-hot-loader patch to fix this. You can't just put all of the application's state in the store.
Literature (by react-hot-loader's developer): https://medium.com/@dan_abramov/hot-reloading-in-react-1140438583bf#.qonpnqnpp which btw says that he fixed most of it in beta version 3, the same one that is imported in react-static-boilerplate...
Every time I change route using
<Link>
, all my components get reconstructed (not updated, not even mounted again, but the class constructor is called). It makes it impossible to keep component states when changing routes without putting everything in store.Is that really intended? Shouldn't client-side routing just (un-)mount or update components w.r.t url?
Sorry for asking here, but the downside of having a hand-made router is that there is no help to find online by people using another generator.