Bug: react-hooks/exhaustive-deps false postive when use isPending
in useActionState
#32062
Open
Description
React version: 19.0.0, eslint-plugin-react-hooks: 5.1.0
Steps To Reproduce
- Create a
useActionState
value and use the third value in the return value - Use dispatch function in
useEffect
Link to code example:
import type React from 'react';
import { useActionState, useEffect } from 'react';
export const Example: React.FC = () => {
const [_, dispatch, _isPending] = useActionState(() => 0, 0);
useEffect(() => {
dispatch();
}, []); // React Hook useEffect has a missing dependency: 'dispatch'. Either include it or remove the dependency array.
const [_2, dispatch2] = useActionState(() => 0, 0);
useEffect(() => {
dispatch2();
}, []); // ok
return null;
};
The current behavior
React Hook useEffect has a missing dependency: 'query'. Either include it or remove the dependency array.
The expected behavior
No lint errors.
Only handled 2 elements.