You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug: React-hot-loader works not fine with React.useEffect. React.useEffect's callback function will be called regardless of whether the dependent project get changed when page is updated.
Expected behavior
If the dependencies are not changed, callback should not be triggered.
Environment
React Hot Loader version: 4.13.0
Run these commands in the project folder and fill in their results:
node -v: 14.15.1
npm -v: 6.14.8
Then, specify:
Operating system: macOS Catalina 10.15.5
Browser and version: Google Chrome | 86.0.4240.198
Reproducible Demo
View the code below, when I edit the content of p, state count will be increased.
import { hot } from 'react-hot-loader/root';
import React, { useEffect, useState } from 'react';
function Page() {
const flag = 0;
const [count, setCount] = useState(0);
useEffect(() => {
setCount(count + 1);
}, [flag]);
return (
<>
<h1>{count}</h1>
<p>Hello world!</p>
</>
);
}
export default hot(Page);
The text was updated successfully, but these errors were encountered:
When any file got changed alluseEffect/useMemo is reset. React-Hot-Loader cannot determine how the React tree is "connected" to the module system, so it nukes everything.
Fast Refresh works a little differently and actually knows more about updates. Consider migrating to it - #1453
Description
Bug: React-hot-loader works not fine with React.useEffect. React.useEffect's callback function will be called regardless of whether the dependent project get changed when page is updated.
Expected behavior
If the dependencies are not changed, callback should not be triggered.
Environment
React Hot Loader version: 4.13.0
Run these commands in the project folder and fill in their results:
node -v
: 14.15.1npm -v
: 6.14.8Then, specify:
Reproducible Demo
View the code below, when I edit the content of p, state count will be increased.
The text was updated successfully, but these errors were encountered: