chore: Fixed reset model#271
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Code Review
This pull request refactors the WidgetList component to use useMemo for the dashboard list and introduces a 400ms delay for the run function in the FitOnRefocus component. A review comment highlights the need for a cleanup function in the useEffect hook to clear the setTimeout and avoid potential memory leaks, while also questioning the use of a hardcoded delay.
| } | ||
| run() | ||
|
|
||
| setTimeout(run, 400) |
There was a problem hiding this comment.
The setTimeout call is missing a cleanup function. When using timers inside useEffect, it is important to clear them to prevent the callback from executing after the component has unmounted or when dependencies change. This avoids potential memory leaks and ensures that the run function doesn't execute with stale closure values.
Additionally, the use of a hardcoded delay (400ms) is a "magic number" that might lead to inconsistent behavior. Consider if there is a more deterministic way to signal that the model is ready for the bounds calculation.
const timer = setTimeout(run, 400)
return () => clearTimeout(timer)
No description provided.