Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HMR not working with Stateless components? #465

Closed
ryanswrt opened this issue Sep 25, 2016 · 7 comments
Closed

HMR not working with Stateless components? #465

ryanswrt opened this issue Sep 25, 2016 · 7 comments

Comments

@ryanswrt
Copy link
Contributor

Currently, if I create a stateless component, updating it does not trigger HMR re-renders. It may be because https://github.com/danmartinez101/babel-preset-react-hmre is deprecated due to the transform family hot loaders being deprecated https://github.com/gaearon/react-transform-hmr - there are a few issues suggesting changing to https://github.com/gaearon/react-hot-loader 's V3 release (which is still in beta)

Has anyone tried this out?

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Sep 26, 2016

I actually just got React Hot Loader 3 beta working on the 1.0 branch. See 5185c3a

Would you like to try backporting this to the 0.x line? It should be fairly straightforward. React-hot-loader 3 beta has been stable in my testing. For backporting, just move things from the app.js to web-entry.js.

@ryanswrt
Copy link
Contributor Author

Ok, implemented React Hot Loader 3 (well, removed babel-hmre-preset and used react-hot-loader's appcontainer) here: ryanswrt@3768886

It still doesn't seem to do HMR on stateless components when they're exported though? Stateless components inside stateful components update as expected - not sure if I've overlooked something here, is the transition to webpack-dev server also necessary?

@ryanswrt
Copy link
Contributor Author

Just realized that npm link isn't the only thing required to update gatsby - the locally installed version also needs to be updated (of course). Doing so indicates that it isn't implemented properly in that commit yet - element being passed to the container is undefined, will resolve now

@ryanswrt
Copy link
Contributor Author

Ok - it seems that with my implementation, import { AppContainer } from 'react-hot-loader' results in an undefined AppContainer, as importing the 'react-hot-loader' module by itself results in a sourcemap wrapper - no idea why this is happening; not going to dig into it further for the time being - will rather see if I can test out the alpha instead

@KyleAMathews
Copy link
Contributor

You might be running into a similar problem as I did — make sure you've removed all the old hot reloading stuff (include the hapi-webpack plugin) and then run npm prune.

@ryanswrt
Copy link
Contributor Author

If the hapi-webpack plugin is removed, it needs to be replaced with webpack-dev-server right? Seems like quite a few things were re-written to support that - my naive swap runs the dev server but webpack doesn't seem to be compiling a serve able bundle (but tests pass?)

@KyleAMathews
Copy link
Contributor

Yes it does. Look at my commit, it's all there.
On Tue, Sep 27, 2016 at 1:01 AM Ryan Swart notifications@github.com wrote:

If the hapi-webpack plugin is removed, it needs to be replaced with
webpack-dev-server right? Seems like quite a few things were re-written to
support that - my naive swap runs the dev server but webpack doesn't seem
to be compiling a serve able bundle (but tests pass?)


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#465 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEVh9uLHTLIsAeCNedStoQo2xsHQCa9ks5quM1jgaJpZM4KF5f9
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants