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
3.0.0-beta.6: Component gets mounted twice #457
Comments
Same problem |
I just ran into this same problem today as well, but I don't think it is actually the fault of RHL. It only seems to occur when RHL tries to update a module and is unable to do so. It does produce a warning stating something to that affect. Once that happens, calls to methods of React.Component start to produce errors similar to those reported by @ianks. If I perform a full refresh of the browser, forcing a proper update of the modules reporting the errors, the errors go away and everything then works as expected. The follow up then is, what would prevent RHL from being able to being able to update a module and what should I be doing in order to make sure my components don't choke RHL? More info: upon closer inspection, the issue is limited to methods called on a
|
@ianks : this is not a problem with RHL, you are stepping on your own feet here and causing this to happen. The docs for
https://facebook.github.io/react/docs/react-component.html#componentdidmount Move any BTW, you probably want to review your webpack config. It seems to contain a number of errors as well. |
This will cause another re-rendering (which is fine), it should not trigger a re-mount. |
I am having a similar issue but dont do setState in the component. When I have the 'react-hot-loader/babel' preset set any of my onMouseEnters that trigger a setState will create this error. Commenting it out fixes it . |
I just run into the same The error was caused by the fact that I still had Not sure if this is the same problem as you're having -- but thought I'd share in case others run into this. |
I also go the setState error with webpack & typescript. I noticed removing the "react-hot-loader/patch" from my webpack entry stopped the error. If your using typescript and changing the tsconfig.json |
Same issue, move |
@Meeeeow You should not be calling
|
@mutsys
My component will send XHR request to load data and set loading status in state, i should use |
@impaler Thank you! I was in a same situation but solved by removing the "react-hot-loader/patch" from entry.
|
I had this issue when trying to switch from
|
This is completely solved in React Hot Loader v4. |
Description
When RHL3, I am seeing this warning when files are updated:
This is happening because I have a function which calls
setState
incomponentDidMount
. However, the component'scomponentDidMount
is called twice; meaning that setState can be called when a component is unmounted.Expected behavior
I would expect
componentDidMount
to be called once after hot reloading.Actual behavior
``componentDidMount` is called twice.
Environment
React Hot Loader version:
Run these commands in the project folder and fill in their results:
node -v
: v6.9.1Then, specify:
Reproducible Demo
The project I am on is huge; and creating a reproducible demo would take a couple hours. So here are my config options. If this proves unhelpful, I will spend more time to try and create one. My goal is to see if anyone else has experienced this issue, and if anyone has fixed this before.
Things to note:
The text was updated successfully, but these errors were encountered: