fix: separate the internal ref from the external one for correct operation of useImperativeHandle and getBoundingClientRect#738
fix: separate the internal ref from the external one for correct operation of useImperativeHandle and getBoundingClientRect#738exzos28 wants to merge 2 commits intocallstack:mainfrom
useImperativeHandle and getBoundingClientRect#738Conversation
…ation of `useImperativeHandle` and `getBoundingClientRect`
createRef with useRef for refs and handle onSlidingComplete callback exzos 5 minutes agouseImperativeHandle and getBoundingClientRect
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| return ( | ||
| <View | ||
| ref={containerRef} | ||
| ref={containerRef as any} |
There was a problem hiding this comment.
Bug: Ref Typing Issue Breaks DOM Access
The forwardedRef no longer provides access to the component's DOM element, instead only exposing the updateValue imperative handle. This breaks consumers expecting DOM access (e.g., getBoundingClientRect). The internal containerRef is typed as HTMLElement but requires as any when assigned to the View component, indicating a type mismatch and bypassing type safety.
There was a problem hiding this comment.
Stupid comment. forwardedRef never provided DOM access, and it was replaced by the imperative ref handle.
|
anyone? |
|
up |
Summary:
Here, a single ref is used both for working with
useImperativeHandleand for obtaining the position viagetBoundingClientRect.However, when calling
getBoundingClientRect, the ref does not exist. It is likely that the implementation ofuseImperativeHandlehas changed in React19 and itscreateHandlecallback overrides current.updateValuevia ref - always call theonValueChangecallback.Test Plan:
I've create an
ControlledSliderExampleinsrc/Examples:Screen.Recording.2025-10-14.at.15.12.43.mov