Skip to content

linter: react/no-unstable-nested-components false positive on event handlers that pass JSX to functions #22608

Description

@pbomb

What version of Oxlint are you using?

1.66.0

What command did you run?

oxlint --rule react/no-unstable-nested-components

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

{
  "rules": {
    "react/no-unstable-nested-components": "error"
  }
}

What happened?

The rule fires on event handler callbacks that pass JSX to a helper function like showToast. These are not component definitions — the arrow function does not return JSX.

Minimal reproduction:

function MyComponent() {
  return (
    <Button
      onClick={() => {
        showToast(<Toast label=\"Button clicked\" />);
      }}
    />
  );
}

The onClick handler never returns JSX — it calls showToast as a side effect. The <Toast /> element is an argument to a function call, not an inline component definition.

Other patterns that incorrectly trigger:

useMutation(MUTATION, {
  onCompleted: (data) => {   // ← flagged, but this is a void callback
    if (data.errors) { showToast(<ErrorToast />); }
  },
});

Expected behavior

The rule should only fire when an arrow function returns JSX (render prop / component factory). It should not fire when JSX is merely passed as an argument inside a void callback. The eslint-plugin-react implementation does not flag these patterns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions