-
Notifications
You must be signed in to change notification settings - Fork 49k
Closed
Labels
Component: React CompilerStatus: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bugType: Bug
Description
What kind of issue is this?
- React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
- babel-plugin-react-compiler (build issue installing or using the Babel plugin)
- eslint-plugin-react-compiler (build issue installing or using the eslint plugin)
- react-compiler-healthcheck (build issue installing or using the healthcheck script)
Link to repro
Repro steps
import * as React from 'react';
export function useResizeHandle(
target: React.MutableRefObject<HTMLDivElement | null>,
) {
const bar = React.useRef<HTMLDivElement>(null);
React.useEffect(() => {
function resizeObject(event: MouseEvent | TouchEvent) {
bar.current.style.width = "10px";
target.current.style.width = "10px";
// ~~ InvalidReact: Mutating component props or hook arguments is not allowed. Consider using a local variable instead. Found mutation of `target`
}
document.addEventListener('mousemove', resizeObject, { passive: false });
return () => {
document.removeEventListener('mousemove', resizeObject);
};
}, [target]);
return {
dragging: true,
};
}
This seems like the same as #29196 but in reverse.
From what @josephsavona said:
we will likely need to explore a heuristic for understanding which values may be refs, based on the ecosystem convention of "ref" or "-Ref".
This could make sense. I could see myself doing:
export function useResizeHandle(
- target: React.MutableRefObject<HTMLDivElement | null>,
+ targetRef: React.MutableRefObject<HTMLDivElement | null>,
) {
How often does this bug happen?
Every time
What version of React are you using?
v19
flaviendelangle, SukkaW, oliviertassinari, huynhducduy and BellCubeDev
Metadata
Metadata
Assignees
Labels
Component: React CompilerStatus: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bugType: Bug