-
Notifications
You must be signed in to change notification settings - Fork 801
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
Infinite render loop in 4.12.1 and up. #1294
Comments
I've checked code changes between 4.12.0 and 4.12.1 and there is only one place related not related to hooks, and it's quite small. |
I did some further testing, and this only happens when there are 2 nested components at the root with |
Ok, sounds like infinity loops in hooks. cc @natew So:
<Component1>
<Component2/>
</Component1>
Just help me reproduce it. |
I was able to reproduce it with 1 component, here are the details:
import { hot } from 'react-hot-loader/root'
import { Provider } from 'react-redux'
import store from './store'
import { MyComponent1 } from './test'
const App = () => (
<Provider store={store}>
<MyComponent1>
test
</MyComponent1>
</Provider>
)
export default hot(App)
import React from 'react'
import { connect } from 'react-redux'
export class MyComponent1 extends React.Component {
render() {
return (
<div>
{this.props.children}
</div>
)
}
}
MyComponent1 = connect(state => state, undefined, undefined, {pure: false})(MyComponent1) When I update the test component:
// edit: If any of the child components of MyComponent1 updates the redux store, it also triggers the infinite loop. |
👍I'll update tests and double check. Still not sure how changes between 12.0 and 12.1 might affect it. |
Just want to +1 this. I was having an issue with useSelector in an unrelated component (notifications) causing an infinite render only on a particular unrelated page (neither are using the others redux state or modifying it, especially on render) as reported by this module and when I downgraded to 4.12.0 it works fine and anything above 4.12.1 breaks. Very odd as I said, these components are completely unrelated. When I remove the useSelector it doesn't break :/
|
Similar issue here -- but instead of getting an update depth error, Chrome just freezes the page and pegs my CPU at 100%. If I throw a couple console logging lines into my component hierarchy, I can see the whole tree rendering 20-30x/second. Rolling back to my dependencies from last week ([email protected], babel plugins at 7.4.5, etc.) everything works fine. Upgrading react-hot-loader to anything newer (4.12.1-4.12.5) causes the issue. I'm not using react-redux, though it looks like one of my dependencies (react-beautiful-dnd) is. Also, disabling the |
:oof: |
Just wanna confirm the same issue. Didn't spend time to find what exactly causes it in my case, just got rolled back to 4.12.0 as it works perfectly for me now. |
same issue |
Problem has been triaged - related to hooks reloading RHL is adding a dependency the any hook with dependency which represent "hot-reloading sequence"
The problem is with Fix - dont change it if hot replacement is already enabled. |
v4.12.6 released. In my tests everything is good. |
Confirming, the problem no longer occurs in my code. |
Confirming 4.12.6 stops the infinite render loop. However, I'm now seeing that my useState calls get re-initialized when a component hot reloads. I have a component with an input tied to useState. On 4.12.0 if I type something into the input field, then make a change to the component, the component hot reloads but keeps what I typed. On 4.12.6, it clears out what I typed back to the default. I added a useEffect hook that should only print when the component gets unmounted: useEffect(() => {
return () => {
console.log("This should only print when the component gets unmounted");
};
}, []); On 4.12.0, this line never gets printed and my useState values don't get reset. On 4.12.6, it gets printed after hot reloading is complete, at which point my useState values reset. |
@dmarkow - that's another issue, and there are 2 things, which may cause it:
Please create a new issue with an example to reproduce - only you have a broken example (at least yet) |
Hello I got the same issue recently. Did something huge change between 4.12.13 and 4.12.14? Notice that 4.12.14 freezes the tab with infinite loop, with 4.12.15, tab is not freezed but infinite loop can be seen. Can we reopen this issue? |
@GuillaumeCisco - please provide an example to reproduce. It's not known how to cause an infinite loop.
Lets double-check the logs... |
I will try to provide a code to reproduce it, but I think this is the same as before ;) |
我在一个项目中也复现了此问题,经排查,无论高低版本的hot-loader都会出现此问题。 |
This is still happening in 4.13.0 |
Description
For versions 4.12.1 and up (last tested at 4.12.5), my app goes into a infinite render loop, resulting in "Invariant: Maximum update depth exceeded" error displaying in the rhl redbox anytime it hot reloads, or on pages that makes change to redux state. It works fine in 4.12.0.
The error is the result of one of the root components of my app, exported with
react-redux connect
:If I change the
pure
option to true, the problem disappears.Don't have time right now to create a reproducible demo, I'll look into it if its needed.
Expected behavior
It's shouldn't break.
Actual behavior
It goes into an infinite render loop.
Environment
React Hot Loader version: 4.12.1 and up
Run these commands in the project folder and fill in their results:
node -v
: v11.9.0npm -v
: 6.5.0Then, specify:
The text was updated successfully, but these errors were encountered: