Closed zengsai closed 7 years ago
Right now Webpack HMR is used instead. Is there any benefit of using React Hot Loader 3 compared to Webpack HMR?
There is an issue in current version of apollo-fullstack-starter-kit: the state of react component can not retained after changing the component using HMR.
Reproduce flow:
render()
function in "src/ui/containers/counter.jsx", like add a new button and save, to trigger HMR.I'm new to front-end development, and don't know if this about HMR, but after using react-hot-loader 3, this issue is gone.
I aslo added a local timer in Counter component, the timer be reseted every time the HMR be triggered.
Well, if you want reload latest GraphQL data on HMR, you don't need React Hot Loader 3 for this, it's actually easy to do with Webpack HMR, see my commit: https://github.com/sysgears/apollo-fullstack-starter-kit/commit/e5b00521c13325114b5cb81daf35e97cdcb6af96
If you want React Hot Loader 3 to not touch the state of your components on reload, this is not working well. For example if you change your Redux handlers, or some logic inside your query it won't be executed to React Hot Loader 3. And the thing is, 95% of the time I find myself changing "controller or model" code, not presentation "code". For the scenario of changing not presentation code, but "controller or model" code Webpack HMR is far better then React Hot Loader 3. For the scenario of changing purely presentation code React Hot Loader is better then Webpack HMR.
React Hot Loader 3 is not nice to set up. It wants itself to be present in .babelrc and webpack plugins and entry point, e.g. everywhere. This causes difficulties with maintaining dev and prod configs, because in prod config one don't want React Hot Loader 3 to be present in .babelrc
. And the last thing, Dan Abramov, the author of React Hot Loader 3 has left the project.
Because of this, I've decided to exclude React Hot Loader 3 from the project completely and rely on Webpack HMR.
got it! thanks!
@vlasenko do you just leave out the react plugin or do you have substitute configs? The latest webpack docs site references using React Hot Loader 3: https://webpack.js.org/guides/hmr-react/. Would you answer on StackOverflow maybe?
@rojobuffalo As explained above, pure Webpack HMR is used instead: https://github.com/sysgears/apollo-fullstack-starter-kit/issues/10#issuecomment-261859946
Okay. Perhaps React Hot Loader 3 support will be included as an optional feature to let people see what works best for them, pure Webpack HMR or React Hot Loader 3 + Webpack HMR. But I'm worried about additional code complexity that this brings in. This starter kit tries to solve many practical problems during development already, maybe even too many.
Is there any plan to using react-hot-loader 3 ?