Skip to content

Bug: exhaustive-deps rule doesn't report for useInsertionEffect #31308

@luin

Description

@luin

React version: 18
eslint-plugin-react-hooks version: 4.6.2

Steps To Reproduce

Run eslint. with eslint-plugin-react-hooks with the following two code:

  1. useEffect:
const App = ({ id }: { id: string }) => {
  useEffect(() => {
    document.title = id;
  }, []);
};
  1. useInsertionEffect:
const App = ({ id }: { id: string }) => {
  useInsertionEffect(() => {
    document.title = id;
  }, []);
};

The current behavior

The plugin reports a warning for the first case and doesn't for the second.

The expected behavior

For both cases the plugin should report a warning.

As a workaround, I currently have to update the config:

        'react-hooks/exhaustive-deps': [
          'warn',
          {
            additionalHooks: 'useInsertionEffect',
          },
        ],

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: StaleAutomatically closed due to inactivityStatus: 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