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
When this component gets hot reloaded, a log line is printed.
variable changed "hello" "hello"
If this is an effect from the component getting remounted, I'd expect the ref to be cleared, oldValueRef.current to be undefined at the time the log is printed, and we would see
variable changed undefined "hello"
If it is just getting rerendered, the useEffect shouldn't be triggered from an unchanged string dependency, and there should be no logs at all.
What could cause this?
Package versions in use:
@pmmmwh/react-refresh-webpack-plugin 0.5.11
react-refresh 0.14.0
react 18.2.0 NOT using StrictMode (this definitely looks like StrictMode behaviour, but isn't)
webpack 4.46.0
The text was updated successfully, but these errors were encountered:
foucdeg
changed the title
useEffect inside refreshed code runs needlesslyuseEffect inside refreshed code runs needlessly
Mar 13, 2024
This is a component with a "mock"
useEffect
that tracks changes to variables.When this component gets hot reloaded, a log line is printed.
If this is an effect from the component getting remounted, I'd expect the ref to be cleared,
oldValueRef.current
to be undefined at the time the log is printed, and we would seeIf it is just getting rerendered, the
useEffect
shouldn't be triggered from an unchanged string dependency, and there should be no logs at all.What could cause this?
Package versions in use:
@pmmmwh/react-refresh-webpack-plugin
0.5.11react-refresh
0.14.0react
18.2.0 NOT usingStrictMode
(this definitely looks like StrictMode behaviour, but isn't)webpack
4.46.0The text was updated successfully, but these errors were encountered: