[M2] IgviewerCanvas mutates the DOM canvas during render + bogus effect dependency #23
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
indigocode/igasset-viewer-react#23
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
File:
packages/viewer-react/src/IgviewerCanvas.tsxTwo issues:
Side effect during render (lines 21-33): the component resizes
canvas.width/canvas.heightand reads thedevicePixelRatioglobal during the render phase. This is an impure render side effect that React 18+ concurrent rendering / StrictMode may double-invoke. Move it into the rAF tick or a layout effect.Bogus effect dependency (line 62):
useEffect(..., [runtime, canvasId, canvasRef.current])listscanvasRef.currentas a dependency. Refs don't trigger re-renders, so this dependency is dead/misleading, andreact-hooks/exhaustive-depswould flag it.Filed by an automated AI code review (manual proof-of-concept run). Code locations reference the
various-cleanupbranch.