Is it safe to use ref.current as useEffect’s dependency when ref points to a DOM element?

It isn’t safe because mutating the reference won’t trigger a render, therefore, won’t trigger the useEffect. React Hook useEffect has an unnecessary dependency: ‘ref.current’. Either exclude it or remove the dependency array. Mutable values like ‘ref.current’ aren’t valid dependencies because mutating them doesn’t re-render the component. (react-hooks/exhaustive-deps) An anti-pattern example: const Foo = () => … Read more