Skip to content

Bug: react-hooks/exhaustive-deps false postive when use isPending in useActionState #32062

Open
@dislido

Description

React version: 19.0.0, eslint-plugin-react-hooks: 5.1.0

Steps To Reproduce

  1. Create a useActionState value and use the third value in the return value
  2. 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.

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions