Several components in the project contain useEffect hooks that are missing required dependencies in their dependency arrays. This can lead to unpredictable behavior, stale closures, and bugs that are hard to trace.
Examples:
useEffect(() => {
setDescription(server?.description || "");
setTab(server?.endpoint ? TAB_ENDPOINT : TAB_SIMPLE);
setIp(server?.ip || "");
setVersion(server?.version ?? getDefaultVersion());
setEndpoint(server?.endpoint || "");
}, [server, versions]); // React Hook useEffect has a missing dependency: 'getDefaultVersion'. Either include it or remove the dependency array
Also run npm run lint and you'll get a bunch useEffect dep warnings
Why This Matters:
- React relies on the dependency array to determine when to re-run the effect.
- Omitting dependencies can cause effects to run with outdated values.
- This violates the [Rules of Hooks](https://reactjs.org/docs/hooks-rules.html) and may trigger warnings in strict mode or linters like
eslint-plugin-react-hooks.
Suggested Fixes:
- Audit all
useEffect hooks and ensure dependency arrays include all referenced variables.
- Consider enabling
react-hooks/exhaustive-deps in ESLint to catch these automatically.
- Refactor effects to avoid unnecessary re-renders or extract logic into memoized callbacks if needed.
Steps to Reproduce:
- Navigate to any component using
useEffect with an empty dependency array.
- Modify a prop or state used inside the effect.
- Observe that the effect does not re-run as expected.
#27 should be merged first before this is addressed
Several components in the project contain
useEffecthooks that are missing required dependencies in their dependency arrays. This can lead to unpredictable behavior, stale closures, and bugs that are hard to trace.Examples:
Also run
npm run lintand you'll get a bunch useEffect dep warningsWhy This Matters:
eslint-plugin-react-hooks.Suggested Fixes:
useEffecthooks and ensure dependency arrays include all referenced variables.react-hooks/exhaustive-depsin ESLint to catch these automatically.Steps to Reproduce:
useEffectwith an empty dependency array.#27 should be merged first before this is addressed