-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
docs(guides): fix HMR Gotcha section snippet (#1463) #1464
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
Conversation
@maheshpec does this resolve the issue you opened, #1463? Also, I think your issue may overlap with #1461 so I may close yours in favor of the first but I will double check before doing so. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think maybe we should re-organize this whole code block a bit -- typically if (module.hot)
statements are found at the bottom of modules. Also, in this case I think it makes more sense logically to include it at the bottom of the file as it's dependent on previously defined variables and runs after the other code in the file.
Ok, so I re-organized the block as @skipjack mentioned. I am not getting any kind of error, but the warning is still showing up: As you can see the My guess was that somehow webpack was trying to update the module twice, and it is only being accepted the first time. I thought it had something to do with having both So when I removed By the way I added the Still not sure if I am doing anything else wrong... |
I think @sbaidon is right. It is trying to load it twice - once for the if(module.hot._main) {
return {
type: "unaccepted",
chain: chain,
moduleId: moduleId
};
} IMHO the approach to fix would be to add a Preparation section which removes the print entry point. Please let me know what you guys think |
@maheshpec @sbaidon yes good catch and @maheshpec thank you for updating! I should've caught that earlier, you shouldn't have an entry file that's consumed by another module without using the As soon as the build passes, I'll get this merged so we can close out #1461. |
@@ -94,6 +88,13 @@ __index.js__ | |||
} | |||
|
|||
document.body.appendChild(component()); | |||
+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's just this extra plus sign left
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's ok, it's just indicating that a new line was added in between the last line of the script and new content. That's how we've done it in the other guides as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah or maybe you meant there's two plus signs? That's actually just a looking at a diff
within a diff
issue 😆 (there's really only one in the document).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a little confusing to view these diffs :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah like some kind diff inception lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I did mean that the new line was added, but if that's how it has been done on the other guides is fine 👍
Fix for snippet in the Gotcha section of Hot Module Replacement Guide.
Resolves #1461