Skip to content

Bug: False postive react-hooks/refs #35997

@retyui

Description

@retyui

Since React 19 devs can pass ref directly as a prop (forwardref is not needed anymore) , but now eslint-plugin-react-hooks is complaining about valid code

Image

React version: 19.1.1
eslint-plugin-react-hooks: 7.0.1

Steps To Reproduce

import type { Ref } from 'react';
import {
  StyleProp,
  TextInput as RNTextInput,
  TextInputProps,
  TextStyle,
} from 'react-native';

import { TextInput } from '../TextInput';

function TextArea(
  props: TextInputProps & {
    ref?: Ref<RNTextInput | null>;
    style?: StyleProp<TextStyle>;
  },
) {
  return (
    <TextInput
      ref={props.ref} // Eslint error: react-hooks/refs
      type="body"
    />
  );
}

export { TextArea };

The current behavior

Error
ref={props.ref} // Eslint error: react-hooks/refs

The expected behavior

No error, valid react 19 code

Metadata

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