Repository navigation
fix(WEBVIEW-002): CU-17tkuw60edv parallax-image-showcase stores the raw DOMRect in state on every resize/scroll - #2626
flamingo[bot] wants to merge 1 commit into
Conversation
…tate on every resize/scroll
| const mouseYSpring = useSpring(mouseY, springConfig); | ||
|
|
||
| // Track component position for global mouse calculations | ||
| const [componentRect, setComponentRect] = useState<DOMRect | null>(null); |
There was a problem hiding this comment.
🦩 🔵 parallax-image-showcase stores the raw DOMRect in state on every resize/scroll
In ParallaxImageShowcase, replaced const [componentRect, setComponentRect] = useState<DOMRect | null>(null) with const componentRectRef = useRef<DOMRect | null>(null). The updateRect resize/scroll handler in the first useEffect now assigns componentRectRef.current = ... instead of calling setComponentRect, so resize/scroll no longer trigger a re-render. The mousemove handler in the second useEffect now reads componentRectRef.current instead of the componentRect state, and that effect's dependency array was updated from [componentRect, mouseX, mouseY] to [mouseX, mouseY] since the ref no longer needs to be a reactive dependency. Removed the now-unused useState import. The derived values actually rendered from (mouseX/mouseY motion values, scroll/mouse transforms) are untouched and continue to drive framer-motion via refs/motion values rather than React state.
🤖 Prompt for AI agents
In openframe-frontend-core/src/components/features/parallax-image-showcase.tsx around line 46, review and complete this code-review fix: parallax-image-showcase stores the raw DOMRect in state on every resize/scroll.
What the draft fix changed: In `ParallaxImageShowcase`, replaced `const [componentRect, setComponentRect] = useState<DOMRect | null>(null)` with `const componentRectRef = useRef<DOMRect | null>(null)`. The `updateRect` resize/scroll handler in the first `useEffect` now assigns `componentRectRef.current = ...` instead of calling `setComponentRect`, so resize/scroll no longer trigger a re-render. The mousemove handler in the second `useEffect` now reads `componentRectRef.current` instead of the `componentRect` state, and that effect's dependency array was updated from `[componentRect, mouseX, mouseY]` to `[mouseX, mouseY]` since the ref no longer needs to be a reactive dependency. Removed the now-unused `useState` import. The derived values actually rendered from (mouseX/mouseY motion values, scroll/mouse transforms) are untouched and continue to drive framer-motion via refs/motion values rather than React state.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer
Closes findings from rule WEBVIEW-002 — parallax-image-showcase stores the raw DOMRect in state on every resize/scroll.
Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
openframe-frontend-core/src/components/features/parallax-image-showcase.tsx:46What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.
Run: https://product-hub.flamingo.so/admin/code-review
Run id:
c40b7363-145c-433c-a3bc-3b4b3af00901Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.
ClickUp task: CU-17tkuw60edv DOMRect state churn in parallax component (1 PRs)