Skip to content

Add missing (empty) dependency array to useEffect()#6849

Open
megatwig wants to merge 4 commits intostashapp:developfrom
megatwig:useeffect-deps
Open

Add missing (empty) dependency array to useEffect()#6849
megatwig wants to merge 4 commits intostashapp:developfrom
megatwig:useeffect-deps

Conversation

@megatwig
Copy link
Copy Markdown

useEffect without a dependency array is re-evaluated on every single render.

Most of these are just binding (and unbinding) keyboard shortcuts, so should be pretty safe to update in bulk.

I did spot a couple that skip keybind listeners if !isVisible, so set as a dependency so they'll still get installed.

There's an eslint check which can flag this (and other deps issues) - but the version of eslint-plugin-react-hooks configured is ancient and doesn't seem to have it. I briefly tried upgrading and enabling, but eslint-config-airbnb complains it's too new, and it surfaces 57 new lint errors (222 with with full react-hooks/recommended enabled).

A `useEffect` without a dependency array is re-evaluated on every single render.

Most of these are just binding (and unbinding) keyboard shortcuts, so should be pretty safe to update in bulk.

I did spot a couple that skip keybind listeners if `!isVisible`, so set as a dependency so they'll still get installed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant