Skip to content

Bug: eslint-react-hooks false positives on refs rule #34775

@marcospgp

Description

@marcospgp

after updating eslint-react-hooks from v5 to v6, I'm getting false positives on the rule eslint(react-hooks/refs)

every props.<something> access in the code below is being flagged by this rule, when clearly it is not a ref access.

function FieldInternal(props: FieldBaseProps & { children?: React.ReactNode }) {
  return (
    <F.Root
      name={props.name}
      className="contents"
      validate={(value: unknown) => props.validate?.(value as string) ?? null}
      validationMode={props.validationMode}
    >
      {props.label && <F.Label>{props.label}</F.Label>}
      <div className={`gap-x-sm gap-2xs flex min-w-0 items-start ${props.grow ? "grow" : ""} ${!props.label ? "col-span-2" : ""}`}>
        <div className={`gap-3xs w-md flex min-w-0 flex-col ${props.grow ? "grow" : ""}`}>
          <F.Control
            ref={props.ref}
            placeholder={props.placeholder}
            autoComplete={props.autoComplete}
            autoFocus={props.autoFocus}
            disabled={props.disabled}
            className={`bg-bg-2 px-2xs py-2xs bevel-inset-bg-2 w-full min-w-0 outline-0 data-[disabled]:cursor-not-allowed ${props.disabled && "cursor-not-allowed"}`}
          />
          <F.Error className="text-text-danger min-w-0 text-sm" />
        </div>
        {props.children}
      </div>
    </F.Root>
  );
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions