Repository navigation
fix: make synthetic refs non-enumerable to prevent leaking through rest spreads - #64
Conversation
|
There are integration tests on https://github.com/fullstorydev/fullstory-react-native that must pass. Please run |
…bel-plugin-react-native into fix/react-19-non-enumerable-synthetic-refs
|
Hi @RyanCommits, I've run the integration tests on To enable CI verification via GitHub-based install, I've added:
These are temporary Happy to clean those up once you've confirmed the tests pass on your end. |
Thank you for that. I was running tests locally with the unminified version of your I see in your change that you've gotten rid of checking for the I've tested the following, which passes the tests but preserves the historical logic: In your description you only mention the changes to |
|
This is actually more surgical, preserving identical logic whilst adding |
|
Hi @RyanCommits, Yes, removing the I've updated the PR with your second suggestion and cleaned up all temporary changes. |
Summary
On React 19,
@fullstory/babel-plugin-react-nativeinjects syntheticsharedRefWrapperrefs intoprops.reffor every element with FS attributes on iOS. These synthetic refs are enumerable, so they leak through{...rest}spreads in custom components, overwriting legitimate child refs.This causes broken
ref-dependent behavior (focus, scroll-to, etc.) in any component that spreads remaining props without destructuringreffirst.Fix
Inject the synthetic ref as non-enumerable via
Object.defineProperty, preserving the existingforwardedRefguard. This preserves FS instrumentation (React'scoerceRefreadselement.props.refvia direct property access, which works regardless of enumerability) while preventing the ref from appearing in{...rest}spreads.!ref && forwardedRef: skip injection (preserve existing behavior)Object.definePropertywithenumerable: falseinvisible to{...rest}, visible tocoerceRef