#26709·oxc

linter: react-hooks/refs reports the same location multiple times

Author: stevenpollackCreated Sep 16, 2026Updated Sep 16, 2026
LabelsA-linterA-react-compiler

What version of oxlint are you using?

1.81.0

What did you expect to see?

One react(refs) diagnostic per flagged source location.

What did you see instead?

Four identical diagnostics for the same location. The count is not a stable function of the code — editing unrelated statements elsewhere in the same hook moves it between 4 and 6 without changing which line is flagged.

repro.ts:10:17: error react(refs): Cannot access refs during render ...
repro.ts:10:17: error react(refs): Cannot access refs during render ...
repro.ts:10:17: error react(refs): Cannot access refs during render ...
repro.ts:10:17: error react(refs): Cannot access refs during render ...

Reproduction

.oxlintrc.json:

json
{
  "plugins": ["react"],
  "categories": { "correctness": "off", "suspicious": "off", "pedantic": "off", "perf": "off", "style": "off", "restriction": "off", "nursery": "off" },
  "rules": { "react-hooks/refs": "error" }
}

repro.ts:

typescript
import { useEffect, useRef } from 'react';

const clearOwned = (owner: symbol): void => {
  console.log(owner);
};

export const useOwner = (items: number[], index: number, count: number): void => {
  const ownerRef = useRef<symbol | null>(null);
  ownerRef.current ??= Symbol('owner');
  const owner = ownerRef.current;

  useEffect(() => {
    const item = items[index];
    if (count === 0 || item === undefined) {
      clearOwned(owner);
      return;
    }
    console.log(item, owner);
  }, [index, items, count, owner]);

  useEffect(() => () => clearOwned(owner), [owner]);
};

Then oxlint .

Note

Whether this location should be flagged at all is a separate question — [email protected] reports it zero times, filed separately. The duplication is independent of that: it affects any location the rule does report.