-
-
Notifications
You must be signed in to change notification settings - Fork 42
[bug] immutability: false positive on DOM event target mutation #1626
Copy link
Copy link
Closed
Labels
Status: ReleasedThe issue has been releasedThe issue has been releasedType: BugSomething isn't workingSomething isn't working
Description
This issue was written by Claude, an AI assistant.
Rule
react/immutability
Description
The rule flags mutations of native DOM element properties accessed via e.currentTarget in event handlers as immutability violations. These are standard DOM operations, not React state/props mutations.
Repro
import {type KeyboardEvent} from "react";
export function SearchInput() {
function onKeyDown(e: KeyboardEvent<HTMLInputElement>) {
if (e.key === "Escape") {
e.currentTarget.value = ""; // false-positive: react/immutability
}
}
return <input onKeyDown={onKeyDown} />;
}Expected
No error. e.currentTarget is a native DOM element, not a React-managed value.
Actual
Do not mutate 'e.currentTarget' directly. Props and state are immutable — create a new object instead react/immutability
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Status: ReleasedThe issue has been releasedThe issue has been releasedType: BugSomething isn't workingSomething isn't working