Closed
Description
React version: 17.0.1
Steps To Reproduce
Setup eslint with @typescript-eslint/parser as parser
Cast a function passed to useEffect
import {useCallback, useEffect} from 'react';
type F = (...args: unknown[]) => void;
function MyComp() {
const foo = useCallback(() => {}, []);
// OK
useEffect(() => {
foo();
}, [foo]);
// WARNS?
useEffect((() => {
foo();
}) as F, [foo]);
return 'Hello, world'
}
Link to code example: https://github.com/0x24a537r9/exhaustive-deps-bug
The current behavior
The following error was reported
14:2 warning React Hook useEffect received a function whose dependencies are unknown. Pass an inline function instead
The expected behavior
The rule should interpret the function argument correctly and know that it is already inline.