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
The issue seems to be, when I change a state variable with setState, and if I do setState(x) and x is the same as the current state variable inside a useInterval hook, the memory starts to grow. I'm using usehooks-ts but I also tried with other hooks (Dan Abramov's hook and Josh Comeau's hook)
it doesn't leak. I'm aware I can fix it by stopping the interval, but that seems like an optimization and in my original code the delay was slow, so there was not even a need for immediate optimization.
The issue seems to be, when I change a state variable with
setState
, and if I dosetState(x)
andx
is the same as the current state variable inside auseInterval
hook, the memory starts to grow. I'm usingusehooks-ts
but I also tried with other hooks (Dan Abramov's hook and Josh Comeau's hook)This is the code causing the issue:
But if I do:
it doesn't leak. I'm aware I can fix it by stopping the interval, but that seems like an optimization and in my original code the delay was slow, so there was not even a need for immediate optimization.
React version: 18.2.66
Steps To Reproduce
Link to code example:
https://github.com/arturcarvalho/op
Link to deployed code: https://ovp-two.vercel.app/
I don't know how to debug memory leaks on codesandbox, it seems to hide them.
The current behavior
Memory goes up when
setState(x)
wherex
is the same as currentx
on state variable.The expected behavior
Memory not go up when
setState(x)
wherex
is the same as currentx
on state variable.The text was updated successfully, but these errors were encountered: