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

4.0.x broke hot module reloading #193

Closed
aaronjensen opened this issue Oct 11, 2016 · 14 comments
Closed

4.0.x broke hot module reloading #193

aaronjensen opened this issue Oct 11, 2016 · 14 comments
Labels

Comments

@aaronjensen
Copy link
Member

On 3.1.1 hot module reloading for stateless functional components worked. On 4.0.0 and 4.0.1 it no longer does for our project.

@sapegin sapegin added the bug label Oct 11, 2016
@sapegin
Copy link
Member

sapegin commented Oct 11, 2016

I can reproduce it but have no idea why. All HMR configuration should be external.

@aaronjensen
Copy link
Member Author

@sapegin did you change any components from class components to stateless functional components? stateless functional components cannot reload on their own, they must be wrapped at some point by a class component

@sapegin
Copy link
Member

sapegin commented Oct 12, 2016

I did! Now I’m trying to change them back to classes and it doesn’t help ;-(

@tizmagik
Copy link
Collaborator

Hm, I'm not sure if that's it because the root component is a proper class component, so it shouldn't be an issue. I can repro this locally too, not sure what happened. It did reload once but subsequent reloads don't happen, very odd.

@sapegin
Copy link
Member

sapegin commented Oct 12, 2016

I can reproduce this too in the example. Will try to find the exact commit that breaks it.

@sapegin
Copy link
Member

sapegin commented Oct 12, 2016

Here is the bad commit: f713a3e. Unfortunately the biggest one. And here I’ve introduced some functional components.

@aaronjensen aaronjensen mentioned this issue Oct 13, 2016
@sapegin
Copy link
Member

sapegin commented Oct 18, 2016

The only solution I could find is this but I’m not sure it’s better than yours ;-| It’s hack too.

@ Examples.js:15 @
const Examples = ({ examples }) => {
                         <Playground
                             code={example.content}
                             evalInContext={example.evalInContext}
-                             key={index}
+                             key={Math.random()}
                         />
                     );
                 case 'markdown':

@aaronjensen
Copy link
Member Author

that seems worse, it'll recreate everything anytime anything is rerendered won't it?

@sapegin
Copy link
Member

sapegin commented Oct 18, 2016

Yeah, I think you’re right. How about 3cf04d1? Experimenting with your branch.

@sapegin
Copy link
Member

sapegin commented Oct 18, 2016

Actually I like this (vanilla Webpack HMR instead of react-transform-hmr or react-hot-loader) s approach more: no need to configure anything and performance shouldn’t be a big issue because you’d want to develop component in isolated mode anyway.

@aaronjensen
Copy link
Member Author

aaronjensen commented Oct 18, 2016

3cf04d1 looks fine (assuming it works). Which approach are you saying you like more? #200?

@sapegin
Copy link
Member

sapegin commented Oct 18, 2016

Yep, #200 and 3cf04d1 ;-)

@aaronjensen
Copy link
Member Author

Awesome. I'll close this and my pull out. Thanks!

@sapegin
Copy link
Member

sapegin commented Oct 18, 2016

Thank you too, the solution is 90% yours! :shipit:

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

No branches or pull requests

3 participants