[RN] Fix timeStamp property of SyntheticEvent in React Native#35912
Merged
rubennorte merged 1 commit intofacebook:mainfrom Feb 26, 2026
Merged
[RN] Fix timeStamp property of SyntheticEvent in React Native#35912rubennorte merged 1 commit intofacebook:mainfrom
rubennorte merged 1 commit intofacebook:mainfrom
Conversation
|
Comparing: 074d96b...eec2df2 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
javache
approved these changes
Feb 26, 2026
github-actions bot
pushed a commit
that referenced
this pull request
Feb 26, 2026
## Summary This fixes the semantics of the `timeStamp` property of events in React Native. Currently, most events just assign `Date.now()` (at the time of creating the event object in JavaScript) as the `timeStamp` property. This is a divergence with Web and most native platforms, that use a monotonic timestamp for the value (on Web, the same timestamp provided by `performance.now()`). Additionally, many native events specify a timestamp in the event data object as `timestamp` and gets ignored by the logic in JS as it only looks at properties named `timeStamp` specifically (camel case). This PR fixes both issues by: 1. Using `performance.now()` instead of `Date.now()` by default (if available). 2. Checking for a `timestamp` property before falling back to the default (apart from `timeStamp`). ## How did you test this change? Added unit tests for verify the new behavior. DiffTrain build for [a48e9e3](a48e9e3)
emmaeng700
added a commit
to emmaeng700/react
that referenced
this pull request
Feb 26, 2026
In StrictMode, `doubleInvokeEffectsInDEVIfNecessary` fires for any fiber that has the `PlacementDEV` flag set. Previously, `placeChild` set `PlacementDEV` on both newly inserted fibers AND fibers that were moved to a different position in an array. This caused a regression in React 19: when a keyed child is reordered within an array, its effects are re-run in dev/StrictMode even when dependencies are empty `[]`. The same component in production, or in React 18, correctly skips effect re-runs for moves. The fix is to only set `PlacementDEV` for actual insertions (where `current === null`). Moved fibers (`current !== null`, `oldIndex < lastPlacedIndex`) still receive the `Placement` flag so the host node is correctly repositioned in the DOM, but StrictMode no longer treats them as new mounts. Also fix unused `ref3` variable in ReactFabric-test.internal.js introduced in facebook#35912 (copy-paste: third View used ref2 instead of ref3). Fixes facebook#32561
rubennorte
added a commit
that referenced
this pull request
Mar 3, 2026
…Native (#35947) ## Summary This defines the same fiber configuration for RN as used in DOM, so we can expose event timing information in the React scheduler tracks in performance traces. This was unblocked by #35913 and #35912. ## How did you test this change? Manually compiled the renderer and tested e2e in FB infra: <img width="1217" height="161" alt="Screenshot 2026-03-03 at 10 10 44" src="https://github.com/user-attachments/assets/6ca1512e-dcaf-49cf-8da9-1c6ae554733a" />
github-actions bot
pushed a commit
that referenced
this pull request
Mar 3, 2026
…Native (#35947) ## Summary This defines the same fiber configuration for RN as used in DOM, so we can expose event timing information in the React scheduler tracks in performance traces. This was unblocked by #35913 and #35912. ## How did you test this change? Manually compiled the renderer and tested e2e in FB infra: <img width="1217" height="161" alt="Screenshot 2026-03-03 at 10 10 44" src="https://github.com/user-attachments/assets/6ca1512e-dcaf-49cf-8da9-1c6ae554733a" /> DiffTrain build for [4cc5b7a](4cc5b7a)
github-actions bot
pushed a commit
to code/lib-react
that referenced
this pull request
Mar 7, 2026
…Native (facebook#35947) ## Summary This defines the same fiber configuration for RN as used in DOM, so we can expose event timing information in the React scheduler tracks in performance traces. This was unblocked by facebook#35913 and facebook#35912. ## How did you test this change? Manually compiled the renderer and tested e2e in FB infra: <img width="1217" height="161" alt="Screenshot 2026-03-03 at 10 10 44" src="https://github.com/user-attachments/assets/6ca1512e-dcaf-49cf-8da9-1c6ae554733a" /> DiffTrain build for [4cc5b7a](facebook@4cc5b7a)
github-actions bot
pushed a commit
to code/lib-react
that referenced
this pull request
Mar 7, 2026
…Native (facebook#35947) ## Summary This defines the same fiber configuration for RN as used in DOM, so we can expose event timing information in the React scheduler tracks in performance traces. This was unblocked by facebook#35913 and facebook#35912. ## How did you test this change? Manually compiled the renderer and tested e2e in FB infra: <img width="1217" height="161" alt="Screenshot 2026-03-03 at 10 10 44" src="https://github.com/user-attachments/assets/6ca1512e-dcaf-49cf-8da9-1c6ae554733a" /> DiffTrain build for [4cc5b7a](facebook@4cc5b7a)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes the semantics of the
timeStampproperty of events in React Native.Currently, most events just assign
Date.now()(at the time of creating the event object in JavaScript) as thetimeStampproperty. This is a divergence with Web and most native platforms, that use a monotonic timestamp for the value (on Web, the same timestamp provided byperformance.now()).Additionally, many native events specify a timestamp in the event data object as
timestampand gets ignored by the logic in JS as it only looks at properties namedtimeStampspecifically (camel case).This PR fixes both issues by:
performance.now()instead ofDate.now()by default (if available).timestampproperty before falling back to the default (apart fromtimeStamp).How did you test this change?
Added unit tests for verify the new behavior.