Commit Graph

113 Commits

Author SHA1 Message Date
Jakub Piasecki aedf8c1dba Update virtualized-lists types to align them closer to TS definitions (#49264)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49264

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D69308531

fbshipit-source-id: 29f1726026aa55e4e17616e7880c7d30eae13b8f
2025-02-11 09:25:22 -08:00
Jakub Piasecki b8e2bcd60d Update types in virtualized-lists so that they produce valid TS output (#49263)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49263

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D69308533

fbshipit-source-id: 36dd38a5bfce3b19eabcf04ef5f14e006d581bcd
2025-02-11 09:25:22 -08:00
Jakub Piasecki 1cf4c84ba0 Update files in packages/virtualized-lists to use export syntax (#49262)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49262

Changelog: [General][Breaking] Deep imports into `react-native/virtualized-lists` with require syntax may need to be appended with `.default`

Reviewed By: huntie

Differential Revision: D69308532

fbshipit-source-id: 6de15d46e0931616bc9849edbccb7cf745e15dd5
2025-02-11 09:25:22 -08:00
Riccardo Cipolleschi e77fe5c471 Bump React Native monorepo packages (#48975)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48975

After cutting 0.78-stable, we need to bump the monorepo packages to `0.79.0-main`

## Changelog:
[Internal] - Bump monorepo packages to `0.79.0-main`

Reviewed By: cortinico, huntie

Differential Revision: D68715005

fbshipit-source-id: cb5abbf05e8638683687be8d61d66b3037111572
2025-01-27 11:01:34 -08:00
Tim Yung c8a387c2d1 VirtualizedList: Delete Batchinator (#48515)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48515

Deletes `Batchinator`, inlines the timer, and cleans up the `disableInteractionManagerInBatchinator` feature flag.

Changelog:
[Internal]

Reviewed By: javache, NickGerleman

Differential Revision: D67885194

fbshipit-source-id: 5f3ec71a02cf1f1b382b41a480beed28fc8c5439
2025-01-22 07:14:37 -08:00
Tim Yung 0ead7de5e8 VirtualizedList: More Resilient Unit Tests (#48819)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48819

Currently, `VirtualizedList-test.js` has a subtle dependency on how asynchronous operations are queued. Specifically, it depends on...

- `Batchinator` to use `setTimeout` for...
- `InteractionManager` to use `setImmediate` for...
- `InteractionManager` to resolve a promise via microtask.

As a consequence, any changes to this queueing logic (e.g. eliminating the unnecessary `setImmediate` and microtask) unnecessarily breaks these unit tests.

This changes the Jest unit tests to instead use `jest. advanceTimersToNextTimer(<step>)` instead of `jest.runOnlyPendingTimers()` so that the unit tests are no longer dependent on these specific queueing logic.

Changelog:
[Internal]

Reviewed By: NickGerleman

Differential Revision: D68449850

fbshipit-source-id: 382b1c0a0d8fade873ccf17a9deb3622a83b8163
2025-01-21 16:43:36 -08:00
Dawid Małecki f36bfe5dfa Remove redundant {||} syntax (#48686)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48686

Changelog:
[Internal] - Removed redundant `{||}` syntax

Reviewed By: javache

Differential Revision: D68205038

fbshipit-source-id: f7d3271142b6443a5859c3b668b7aebd3ce3ef3f
2025-01-15 07:07:01 -08:00
Sam Zhou f8119fc52b Pre-suppress errors in xplat ahead of 0.257.0 release
Summary: Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D67368232

fbshipit-source-id: 23111f62c5731b5a58e15ac8ef2dcd9ea8006573
2024-12-17 18:28:25 -08:00
Riccardo Cipolleschi 4368368ef5 Fix some peer dependencies on React types (#48292)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48292

These dependencies are making the CI on main to fail.

## Changelog:
[General][Fixed] - Fix peer dependencies on React types

Reviewed By: javache, hoxyq

Differential Revision: D67283609

fbshipit-source-id: b325246f5de654a9ccbf7f96eec24434047a38ee
2024-12-16 14:08:19 -08:00
Riccardo Cipolleschi 5a81ceed2a React Native sync for revisions de68d2f...372ec00 (#48196)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48196

X-link: https://github.com/facebook/metro/pull/1400

- **[372ec00c03](https://github.com/facebook/react/commit/372ec00c03 )**: Update ReactDebugInfo types to declare timing info separately ([#31714](https://github.com/facebook/react/pull/31714)) //<Sebastian Markbåge>//
- **[3d2ab01a55](https://github.com/facebook/react/commit/3d2ab01a55 )**: [Flight] Extract special cases for Server Component return value position ([#31713](https://github.com/facebook/react/pull/31713)) //<Sebastian Markbåge>//
- **[1c9b138714](https://github.com/facebook/react/commit/1c9b138714 )**: Don't serialize chunk ids for Hint and Console rows ([#31671](https://github.com/facebook/react/pull/31671)) //<Sebastian Markbåge>//
- **[de68d2f4a2](https://github.com/facebook/react/commit/de68d2f4a2 )**: Register Suspense retry handlers in commit phase ([#31667](https://github.com/facebook/react/pull/31667)) //<Josh Story>//
- **[16d2bbbd1f](https://github.com/facebook/react/commit/16d2bbbd1f )**: Client render dehydrated Suspense boundaries on document load ([#31620](https://github.com/facebook/react/pull/31620)) //<Josh Story>//
- **[5b0ef217ef](https://github.com/facebook/react/commit/5b0ef217ef )**: s/server action/server function ([#31005](https://github.com/facebook/react/pull/31005)) //<Ricky>//
- **[e3b7ef32be](https://github.com/facebook/react/commit/e3b7ef32be )**: [crud] Only export uRC when flag is enabled ([#31617](https://github.com/facebook/react/pull/31617)) //<lauren>//
- **[aba370f1e4](https://github.com/facebook/react/commit/aba370f1e4 )**: Add moveBefore Experiment ([#31596](https://github.com/facebook/react/pull/31596)) //<Sebastian Markbåge>//
- **[1345c37941](https://github.com/facebook/react/commit/1345c37941 )**: Mark all lanes in order on every new render ([#31615](https://github.com/facebook/react/pull/31615)) //<Sebastian Markbåge>//
- **[91061073d5](https://github.com/facebook/react/commit/91061073d5 )**: Mark ping time as update ([#31611](https://github.com/facebook/react/pull/31611)) //<Sebastian Markbåge>//
- **[a9f14cb44e](https://github.com/facebook/react/commit/a9f14cb44e )**: Fix Logging of Immediately Resolved Promises ([#31610](https://github.com/facebook/react/pull/31610)) //<Sebastian Markbåge>//
- **[c11c9510fa](https://github.com/facebook/react/commit/c11c9510fa )**: [crud] Fix deps comparison bug ([#31599](https://github.com/facebook/react/pull/31599)) //<lauren>//
- **[64f89510af](https://github.com/facebook/react/commit/64f89510af )**: [crud] Enable on RTR FB builds ([#31590](https://github.com/facebook/react/pull/31590)) //<lauren>//
- **[7558ffe84d](https://github.com/facebook/react/commit/7558ffe84d )**: [crud] Fix copy paste typo ([#31588](https://github.com/facebook/react/pull/31588)) //<lauren>//
- **[7c254b6576](https://github.com/facebook/react/commit/7c254b6576 )**: Log yielded time in the Component Track ([#31563](https://github.com/facebook/react/pull/31563)) //<Sebastian Markbåge>//
- **[6177b18c66](https://github.com/facebook/react/commit/6177b18c66 )**: Track suspended time when the render doesn't commit because it suspended ([#31552](https://github.com/facebook/react/pull/31552)) //<Sebastian Markbåge>//
- **[eaf2d5c670](https://github.com/facebook/react/commit/eaf2d5c670 )**: fix[eslint-plugin-react-hooks]: Fix error when callback argument is an identifier with an `as` expression ([#31119](https://github.com/facebook/react/pull/31119)) //<Mark Skelton>//
- **[047d95e85f](https://github.com/facebook/react/commit/047d95e85f )**: [crud] Basic implementation ([#31523](https://github.com/facebook/react/pull/31523)) //<lauren>//
- **[92c0f5f85f](https://github.com/facebook/react/commit/92c0f5f85f )**: Track separate SuspendedOnAction flag by rethrowing a separate SuspenseActionException sentinel ([#31554](https://github.com/facebook/react/pull/31554)) //<Sebastian Markbåge>//
- **[053b3cb050](https://github.com/facebook/react/commit/053b3cb050 )**: [crud] Rename Effect type ([#31557](https://github.com/facebook/react/pull/31557)) //<lauren>//
- **[7dd6b9e68a](https://github.com/facebook/react/commit/7dd6b9e68a )**: [crud] Add enableUseResourceEffectHook flag ([#31556](https://github.com/facebook/react/pull/31556)) //<lauren>//
- **[d8afd1c82e](https://github.com/facebook/react/commit/d8afd1c82e )**: [crud] Scaffold initial types ([#31555](https://github.com/facebook/react/pull/31555)) //<lauren>//
- **[3720870a97](https://github.com/facebook/react/commit/3720870a97 )**: Log Render Phases that Never Committed ([#31548](https://github.com/facebook/react/pull/31548)) //<Sebastian Markbåge>//
- **[8a41d6ceab](https://github.com/facebook/react/commit/8a41d6ceab )**: Unify RootDidNotComplete and RootSuspendedWithDelay exit path  ([#31547](https://github.com/facebook/react/pull/31547)) //<Sebastian Markbåge>//
- **[63cde684f5](https://github.com/facebook/react/commit/63cde684f5 )**: (chore): copy fix in <style> precedence error ([#31524](https://github.com/facebook/react/pull/31524)) //<Zack Tanner>//
- **[b01722d585](https://github.com/facebook/react/commit/b01722d585 )**: Format event with "warning" yellow and prefix with "Event: " ([#31536](https://github.com/facebook/react/pull/31536)) //<Sebastian Markbåge>//
- **[c13986da78](https://github.com/facebook/react/commit/c13986da78 )**: Fix Overlapping "message" Bug in Performance Track ([#31528](https://github.com/facebook/react/pull/31528)) //<Sebastian Markbåge>//
- **[4686872159](https://github.com/facebook/react/commit/4686872159 )**: Log passive commit phase when it wasn't delayed ([#31526](https://github.com/facebook/react/pull/31526)) //<Sebastian Markbåge>//
- **[5d89471ca6](https://github.com/facebook/react/commit/5d89471ca6 )**: Export __COMPILER_RUNTIME in stable ([#31540](https://github.com/facebook/react/pull/31540)) //<lauren>//
- **[3644f0bd21](https://github.com/facebook/react/commit/3644f0bd21 )**: Use completedRenderEndTime as the start of the commit phase if it's an immediate commit ([#31527](https://github.com/facebook/react/pull/31527)) //<Sebastian Markbåge>//
- **[8657869999](https://github.com/facebook/react/commit/8657869999 )**: Separate Tracks for Components and Phases ([#31525](https://github.com/facebook/react/pull/31525)) //<Sebastian Markbåge>//
- **[b15135b9f5](https://github.com/facebook/react/commit/b15135b9f5 )**: [ez] Update useMemoCache return type ([#31539](https://github.com/facebook/react/pull/31539)) //<lauren>//

Changelog:
[General][Changed] - Bump React from 18.3.1 to 19.0.0

bypass-github-export-checks
jest_e2e[run_all_tests]

Reviewed By: cortinico

Differential Revision: D67018480

fbshipit-source-id: 39bca3261ffaa8bb7d74187510724d77cc36b196
2024-12-16 06:58:21 -08:00
Andrei Marchenko df7b6ae092 fix item disappearing with scroll in VirtualizedList (#47965)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47965

Changelog: [General] [Changed] - fix item disappearing with scroll in VirtualizedList

It was caused because the function `computeWindowedRenderLimits` collapsed the current window size to just 1 element. So, users start scroll current window increase from {left:0, right:5 } -> {left:0, right:6 } and after some edge cases the window collapsed to `{left:6, right:6 }` which cause to remove all elements and recreate them later. As a result users have a lot of lags and blank pages.

The diff fixes the collapsing window size to 1 element. Also fix other decreasing `left` position even if windowSize more than current amount of elements.

Reviewed By: NickGerleman

Differential Revision: D66334188

fbshipit-source-id: 2162d00d03d64ab6325c0492d87449051e68a4e9
2024-11-26 10:44:30 -08:00
Andrei Marchenko aafe696453 turn on by default optimization for memoization of virtualized list cells (#47724)
Summary:
Changelog: [General] [Changed] - Fix unnececary rerenders of VirtualizedListCells with strictMode={true}

Pull Request resolved: https://github.com/facebook/react-native/pull/47724

Reviewed By: sammy-SC

Differential Revision: D66123469

fbshipit-source-id: 295e10add51bc1c319b8b8e3a9f4874c5e5a386d
2024-11-20 16:00:03 -08:00
Tim Yung 29a0d7c3b2 RN: Feature Flag to Disable InteractionManager in Batchinator (#47690)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47690

Creates a feature flag to evalute the impact of disabling `InteractionManager` in `Batchinator` and synchronously invoking callbacks after the timeout.

This also deletes the `dispose` arguments in `Batchinator` that were unused.

Changelog:
[Internal]

Reviewed By: bvanderhoof

Differential Revision: D66139643

fbshipit-source-id: d17bab0cd25c0c69779686cb435c063f707255e4
2024-11-18 23:12:15 -08:00
Nicola Corti 7e268c9d52 Revert React 19RC to React 18.3.1 (#47380)
Summary:
While we're waiting for 19 stable, let's bring main back to 18.3.1 ahead of the 0.77 branch cut. We'll land this change just after 19 stable lands.

This is a cherry pick of b93b378fa0 which landed in 0.76 already

bypass-github-export-checks

## Changelog:

[INTERNAL] - Revert React 19RC to React 18.3.1

Pull Request resolved: https://github.com/facebook/react-native/pull/47380

Test Plan: CI

Reviewed By: cipolleschi

Differential Revision: D65430775

Pulled By: cortinico

fbshipit-source-id: f0f211754c8ffe5d037fd299e4de52c29d1d7913
2024-11-08 08:27:37 -08:00
Liron Yahdav 61e660b40e Expose some VirtualizedList functions to allow creating VirtualizedListContextProvider outside of VirtualizedList (#47463)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47463

Note this is just a temporary approach which will be cleaned up later.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D65514902

fbshipit-source-id: f722031c5cd34eb1400b3f732fd94c0b03d5434d
2024-11-06 20:15:08 -08:00
Sam Zhou b91a449e7f Cleanup problematic React.ElementRef (#47340)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47340

This diff cleans up some problematic `React.ElementRef<T>` when T is generic type.

Changelog: [Internal]

Reviewed By: alexmckenley

Differential Revision: D65280467

fbshipit-source-id: 71172b16320a10cbc7a8b46dae5d3dd0eb00ba0c
2024-10-31 13:30:17 -07:00
Sam Zhou 3a01a0c9c5 Fix signature of VirtualizedSectionList (#47318)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47318

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D65239931

fbshipit-source-id: c09eaad8d63f6c415e5d07a4d00dd0acc636c6b9
2024-10-30 18:15:03 -07:00
Sam Zhou ad341e3969 Add as const cast and make types readonly to prepare for natural inference (#47184)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47184

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D64859497

fbshipit-source-id: 2cff5e2671e210a4e8cefb5a2d8c0fb56d5a0d1b
2024-10-23 23:32:37 -07:00
Tim Yung c9ea05552f RN: Fix lint/sort-imports Errors (#47109)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47109

Fixes the `lint/sort-imports` errors that are now surfaced after fixing the lint configuration.

For a couple files, I added lint suppressions instead because the unsorted import ordering is important due to interleaved calls with side effects.

Changelog:
[Internal]

Reviewed By: GijsWeterings

Differential Revision: D64569485

fbshipit-source-id: 26415d792e2b9efe08c05d1436f723faae549882
2024-10-18 04:07:02 -07:00
YunPeng Chong 3485e9ed87 Fix onEndReached not being called when getItemLayout is present and we scroll past render window (#46990)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46990

This is a reattempt land D63643856 to fix the scroll onendreached event not firing.

Changelog:
[General][Fixed] - Fix onEndReached not being called when getItemLayout is present and we scroll past render window

Reviewed By: NickGerleman

Differential Revision: D64222424

fbshipit-source-id: 7e22f377d2f754beb39fff2b5c097cea350daa7e
2024-10-14 15:09:25 -07:00
generatedunixname89002005232357 6b2bbcf632 Revert D63643856
Summary:
This diff reverts D63643856

`_highestMeasuredFrameIndex` is not properly invalidated causing issues with previous logic when data size shrinks.

bypass-github-export-checks

Changelog:
[General][Changed] - Revert "Fix onEndReached not being called when getItemLayout is present and we scroll past render window"

Reviewed By: NickGerleman

Differential Revision: D64009287

fbshipit-source-id: 8a21b57f5247fc743e65f9a730ff33a9a89d2bc1
2024-10-08 12:13:10 -07:00
Sam Zhou 9b5fef32f1 Update some React.AbstractComponent type to use component type (#46855)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46855

Prepare for the ref-as-prop typing change in flow.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D63947642

fbshipit-source-id: bec8a2498961b5bc602d86ecb2b5a4b5c4785e09
2024-10-08 09:20:42 -07:00
Nick Gerleman 62b7396bf4 Fix onEndReached not being called when getItemLayout is present and we scroll past render window (#46736)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46736

Copying the comment in code:

> We only call `onEndReached` after we render the last cell, but when getItemLayout is present, we can scroll past the last rendered cell, and never trigger a new layout or bounds change, so we need to check again after rendering more cells.

Changelog:
[General][Fixed] - Fix onEndReached not being called when getItemLayout is present and we scroll past render window

Reviewed By: yungsters

Differential Revision: D63643856

fbshipit-source-id: 9c53789cb15b225ceac353c37cbb67f7beeaf4fb
2024-10-02 15:53:55 -07:00
Rubén Norte 40aaeb7181 Improve FlatList estimates for items not yet laid out (#46487)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46487

Changelog: [General][Fixed] Fixed accuracy of FlatList estimations to determine what elements are visible in the rendering window.

This fixes a bug in FlatList where it thinks that some elements are visible in the rendering window, when they're not. Specifically, if a cell hasn't been laid out yet, it ignores all the information it already has on the ones that had, and estimates its position and offset based on the estimated size of the cells. In this case, if the first element has a larger offset because the list has a header, that offset is ignored in this case.

One observed result of this is that in a list where there's a header and a single cell that occupy the whole rendering window, FlatList thinks it needs to pre-render an additional element because the header is ignored.

Reviewed By: NickGerleman

Differential Revision: D62649060

fbshipit-source-id: 437bae79916707ca1d08784190508a9f7e36688e
2024-09-13 16:18:33 -07:00
Riccardo Cipolleschi 120558c0cd Bump main to 0.77
Summary:
This change bumps the React Native version in main to 0.77

bypass-github-export-checks

## Changelog:
[General][Changed] - Bump main to 0.77-main

## Facebook:
generated by running `js1 publish react-native 0.77.0-main`

Reviewed By: cortinico

Differential Revision: D62575939

fbshipit-source-id: 6d239fca2eed6cfe51f8c37f78d8dc8730c18b8c
2024-09-12 09:23:23 -07:00
Nick Gerleman 524a3f0476 Try fixing bundling outside the repo (#46148)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46148

Try fixing the import path (not sure if access from external modules is allowed though).

Changelog: [Internal]

Reviewed By: realsoelynn

Differential Revision: D61643115

fbshipit-source-id: a840ee375430b0e20050a36b695a5a4c93c29258
2024-08-21 23:19:56 -07:00
Andrei Marchenko 954e294183 perf(virtualized-lists) removing rerender cells for every change of Virtualized list (#46103)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46103

Reducing the boundary of rerender of virtual lists. Previously with prop: "strictMode={true}" the VirtualizedList still re rendered each CellRenderer component. Because method getDerivedStateFromProps generated every time a new uniq state and the cells didn’t have a PureComponent. It helps to improve react performance for lists which have 5+ elements.

I reused recomended approach from react doc https://legacy.reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#what-about-memoization

changelog: [internal]
Optimizing CellRenderer of VirtualizedList

Reviewed By: NickGerleman, sammy-SC

Differential Revision: D61493434

fbshipit-source-id: 917a33e48bd2f18e8ac150e5701d2e7c45dbe879
2024-08-21 14:23:07 -07:00
Sam Zhou a622a43764 Replace all exact React.Element type in react-native with ExactReactElement_DEPRECATED (#45998)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45998

The exact `React.Element` type is deprecated and will be removed in a future version of Flow.

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D61205640

fbshipit-source-id: a029a3a46c7d8d9f94b0b931b991b2ce461151b2
2024-08-13 09:08:44 -07:00
Sam Zhou 5b96e90f77 Replace React.Element<any> and unnecessarily specific React.Element with React.MixedElement (#45923)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45923

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D60872182

fbshipit-source-id: b81fb43968c52cbfdb4a9fa57f1175aabc2a3939
2024-08-06 21:33:08 -07:00
Sam Zhou 4f47b385fa Cleanup all uses of internal flow type React$ElementRef in react-native (#45904)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45904

Flow will error on these dollar types soon. For all the ones changed here, they can all be further simplified.

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D60786768

fbshipit-source-id: e26bf0be1c4a933fc0bd8b59827e10cbd7242a83
2024-08-05 14:51:30 -07:00
Blake Friedman 188a09ef69 fix linting noise (#45465)
Summary:
## Summary:
Fix linting warnings

Changelog: [Internal]

Pull Request resolved: https://github.com/facebook/react-native/pull/45465

Test Plan:
```
$ eslint .
Done in 46.11s.
$ arc f
ok No lint issues.
```

Reviewed By: cipolleschi

Differential Revision: D59805820

Pulled By: blakef

fbshipit-source-id: f33d99a6a06607c3c3762881cc7c182804b981e1
2024-07-17 10:07:00 -07:00
Nick Gerleman 12b64b7824 Loosen SectionList renderItem required return type (#45305)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45305

Allow SectionList render functions to return any React node, instead of just React.Element. This matches VirtualizedList/FlatList, and general Flow component conventions.

Changelog:
[General][Fixed] - Loosen SectionList `renderItem` required return type

Reviewed By: joevilches

Differential Revision: D59404511

fbshipit-source-id: 3055d8f01845ff5ef8ae75b87f60d8cd26dc07b4
2024-07-08 17:40:59 -07:00
Alex Hunt ebf1a7b79b Bump packages for next major release (#45015)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45015

Set package versions to `0.76.0-main` (`0.75-stable` branch was cut).

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D58687399

fbshipit-source-id: 27ed987e4557705845d57d64e7547cddbd982a03
2024-06-26 07:59:49 -07:00
Tim Yung 0dd8224a71 RN/Relay: Bump Dependency to React 19 (#44990)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44990

Upgrades React Native and Relay to depend on React 19, which is currently published as release candidates. This is in preparation for React Native 0.75.

This will depend on updating open source renderers after [facebook/react#29903](https://github.com/facebook/react/pull/29903) is merged.

Changelog:
[General][Changed] - Upgrade to React 19

Reviewed By: robhogan

Differential Revision: D58625271

fbshipit-source-id: f9ad95b18716a9ce02f7cfbcc7248bdfb244c010
2024-06-17 02:59:55 -07:00
Tim Yung 180dbbf0fb RN: Mitigate Remaining Jest Failures for React 19 (#45002)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45002

There are a couple Jest unit test cases for `VirtualizedList-test.js` that require further investigation.

We believe that these are problems with Jest fake timers in the test and not with the component itself, so for now let's skip them so as to unblock the upgrade to React 19.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D58656948

fbshipit-source-id: d52f3ad8277def6eae20cbbc11751d73b769d929
2024-06-17 02:59:55 -07:00
Tim Yung fe06cbfbf3 Add missing acts to VirtualizedList-test and migrate to async act (#44997)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44997

Wrap `VirtualizedList-test` uses of `react-test-renderer` in `act` as appropriate, so as to pass under current React and mostly pass under React 19, with further fixes to come.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D58649295

fbshipit-source-id: 5e0fa791d581fbf004a2ca7eaa5c4b4d9a15ddfe
2024-06-16 23:02:19 -07:00
Rob Hogan a66ba92526 VirtualizedSectionList-test: use act around react-test-renderer create
Summary:
Migrate `VirtualizedSectionList-test` to use `act`-wrapping in prepation for React 19.

Avoid the `react-native/jest/renderer` abstractions as this is a separate package.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58653558

fbshipit-source-id: 0e19fff5c3998fb00b71c3d07100a2064682cb4c
2024-06-16 21:38:01 -07:00
Sam Zhou f4325dac8e Replace direct React.createElement call with jsx in react-native (#44738)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44738

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58004147

fbshipit-source-id: f42c939d92a876b8746703c134b246567846c3ee
2024-05-31 10:06:09 -07:00
Fabrizio Cucci 95de14dc53 Drop unused code + minor lint fixes (#44645)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44645

Changelog: [Internal]

As per title.

Reviewed By: NickGerleman

Differential Revision: D57664819

fbshipit-source-id: 2388bd01c00d814a12de7f2e285b78f207e6012c
2024-05-22 12:11:33 -07:00
Tim Yung abb7070a51 RN/Relay: Upgrade to React v18.3.1 (#44397)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44397

X-link: https://github.com/facebook/metro/pull/1270

Upgrades `react-native` and `relay` to the newly published `react@18.3.1`.

Changelog:
[General][Changed] - Upgrade to `react@18.3.1`

Reviewed By: jackpope

Differential Revision: D56901818

fbshipit-source-id: 423d35205bb533c6a39c0fed25a1ffea1f0bc12d
2024-05-02 16:18:26 -07:00
Sam Zhou 41f525ccae Pre-suppress unsafe string key access errors in xplat/js (#44221)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44221

This diff pre-suppresses errors of the following pattern, to prepare for the next Flow release.

```
declare const obj: {foo: string};
declare const key: string;
obj[key]; // error: invalid-computed-prop
```

Changelog: [Internal]

Reviewed By: alexmckenley

Differential Revision: D56477899

fbshipit-source-id: 5676b8685bd3157a519fe433cfce0fa28e003502
2024-04-23 11:36:14 -07:00
sebmarkbage 78d6873b04 Don't Rethrow Errors at the Root (#28627)
Summary:
Stacked on top of #28498 for test fixes.

### Don't Rethrow

When we started React it was 1:1 setState calls a series of renders and
if they error, it errors where the setState was called. Simple. However,
then batching came and the error actually got thrown somewhere else.
With concurrent mode, it's not even possible to get setState itself to
throw anymore.

In fact, all APIs that can rethrow out of React are executed either at
the root of the scheduler or inside a DOM event handler.
If you throw inside a React.startTransition callback that's sync, then
that will bubble out of the startTransition but if you throw inside an
async callback or a useTransition we now need to handle it at the hook
site. So in 19 we need to make all React.startTransition swallow the
error (and report them to reportError).

The only one remaining that can throw is flushSync but it doesn't really
make sense for it to throw at the callsite neither because batching.
Just because something rendered in this flush doesn't mean it was
rendered due to what was just scheduled and doesn't mean that it should
abort any of the remaining code afterwards. setState is fire and forget.
It's send an instruction elsewhere, it's not part of the current
imperative code.

Error boundaries never rethrow. Since you should really always have
error boundaries, most of the time, it wouldn't rethrow anyway.

Rethrowing also actually currently drops errors on the floor since we
can only rethrow the first error, so to avoid that we'd need to call
reportError anyway. This happens in RN events.

The other issue with rethrowing is that it logs an extra console.error.
Since we're not sure that user code will actually log it anywhere we
still log it too just like we do with errors inside error boundaries
which leads all of these to log twice.
The goal of this PR is to never rethrow out of React instead, errors
outside of error boundaries get logged to reportError. Event system
errors too.

### Breaking Changes

The main thing this affects is testing where you want to inspect the
errors thrown. To make it easier to port, if you're inside `act` we
track the error into act in an aggregate error and then rethrow it at
the root of `act`. Unlike before though, if you flush synchronously
inside of act it'll still continue until the end of act before
rethrowing.

I expect most user code breakages would be to migrate from `flushSync`
to `act` if you assert on throwing.

However, in the React repo we also have `internalAct` and the
`waitForThrow` helpers. Since these have to use public production
implementations we track these using the global onerror or process
uncaughtException. Unlike regular act, includes both event handler
errors and onRecoverableError by default too. Not just render/commit
errors. So I had to account for that in our tests.

We restore logging an extra log for uncaught errors after the main log
with the component stack in it. We use `console.warn`. This is not yet
ignorable if you preventDefault to the main error event. To avoid
confusion if you don't end up logging the error to console I just added
`An error occurred`.

### Polyfill

All browsers we support really supports `reportError` but not all test
and server environments do, so I implemented a polyfill for browser and
node in `shared/reportGlobalError`. I don't love that this is included
in all builds and gets duplicated into isomorphic even though it's not
actually needed in production. Maybe in the future we can require a
polyfill for this.

### Follow Ups

In a follow up, I'll make caught vs uncaught error handling be
configurable too.

---------

DiffTrain build for commit https://github.com/facebook/react/commit/6786563f3cbbc9b16d5a8187207b5bd904386e53.

Changelog:
[Internal]

Reviewed By: kassens

Differential Revision: D55408481

Pulled By: yungsters

fbshipit-source-id: 598aa306369e21cb3e93ad6041a87bfbaa9eef9e

Co-authored-by: Ricky Hanlon <rickhanlonii@gmail.com>
2024-03-29 01:42:24 -07:00
Andrew Coates dbf8e3f5ba Add @types/react as optional peerDependency on packages that use it (#43509)
Summary:
Now that RN is providing TS type information, many of those .d.ts files depend on types from react.  In modern packagemanagers (Ex: pnpm) types/react will not be available to RN since it does not declare it as a dependency.

I also noticed that the types for react-native-popup-menu-android appear to be pointing to the wrong location.

Add types/react as a peerDependency on the packages that have .d.ts files that import from React.
Add types/react to peerDependencyMeta with optional:true to prevent users not using TS from requiring types/react.

## Changelog:

[GENERAL] [ADDED] Added types/react as an optional peerDependency

Pull Request resolved: https://github.com/facebook/react-native/pull/43509

Reviewed By: cortinico

Differential Revision: D55225940

Pulled By: NickGerleman

fbshipit-source-id: 4cbab071928cb925baec45f55461559acc9a54e6
2024-03-25 12:23:16 -07:00
Blake Friedman a380ea55fb Summary: minor fix found in nightly logs from Publish NPM job (#43519)
Summary:
Minor fix to package.json which newer version of npm warn about when publishing, after running `npm pkg fix -ws` on the workspace.

{F1470070110}

## Changelog: [Internal] npm pkg fix -ws

Pull Request resolved: https://github.com/facebook/react-native/pull/43519

Test Plan: eyescloseddog

Reviewed By: cortinico

Differential Revision: D55012872

Pulled By: blakef

fbshipit-source-id: ff3c63a3eefaf56d369219a3d4b32d44d6d842c9
2024-03-18 08:29:10 -07:00
Rubén Norte dceda565bd Fix RN tests in preparation for D54783723 (#43458)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43458

The React sync in D54783723 was failing because some tests were relying on `console.error` being called as `console.error('Some message')` but it was refactored as `console.error('%s..', 'Some message')`, making them fail.

This fixes the tests by formatting the arguments passed to the console functions and checking against that instead.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D54849485

fbshipit-source-id: 0648263614725ea3f9c95b9f9bb13005adae46eb
2024-03-13 08:51:03 -07:00
Rick Hanlon 5126bace65 Fix VirtualizedList-test.js (#43377)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43377

Fixes `VirtualizedList-test.js`, which assumes fake timers (e.g. using `jest.runAllTimers()` and `jest.runOnlyPendingTimers()`) but did not actually use fake timers.

Changelog:
[Internal]

Reviewed By: yungsters

Differential Revision: D54668281

fbshipit-source-id: b14757744bb7a21a4e5573053549c36178826021
2024-03-07 23:19:27 -08:00
Alex Hunt f57be12977 Bump packages for next major release (#43132)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43132

Command run:

```
node scripts/releases/set-version 0.75.0-main --skip-react-native-version
```

Changelog: [Internal]

Reviewed By: lunaleaps, cipolleschi

Differential Revision: D54006327

fbshipit-source-id: 7afe9e7ca3020faf399fdba2221fab8a102c56c7
2024-03-04 07:54:37 -08:00
Sam Zhou 2053364e5a Update hermes-parser and related packages in fbsource to 0.20.0
Summary:
Bump hermes-parser and related packages to [0.20.0](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [internal]

Reviewed By: alexmckenley

Differential Revision: D54368487

fbshipit-source-id: a5a05f1e499ff5d8bda4649433bd285f7215d3da
2024-02-29 14:19:29 -08:00
Biki-das 6204ea36d3 - fixes component unmounting behaviour in itemSeperatorComponent (#43223)
Summary:
Reopen in reference to https://github.com/facebook/react-native/issues/42435 , as it had a lot of commits and fixes making it messed up.
Weirdly when using a [Section List](https://reactnative.dev/docs/sectionlist) specifically when using the [SectionSeperatorComponent](https://reactnative.dev/docs/sectionlist#sectionseparatorcomponent), and adding additional Data on the renderItem List, there is a unmount occurring as the new Data is added, this only happens while using the `SectionSeparatorComponent` and limited to the same

**Here is the Current Behaviour**

https://github.com/facebook/react-native/assets/72331432/0622e789-ddbc-4038-8ccc-a421050eecbf

**Here is the Expected Behaviour After Fixes**

https://github.com/facebook/react-native/assets/72331432/2f0cc3a9-da97-43f5-8a4b-3faca74ae834

The issues is happening because the Parent View gets removed, as we add Data, the separator moves causing the unmount, the solution that i proposed here is to conditionally render to make sure that our separator renders correctly which required to add an empty view as the `itemSeparatorComponent`.

## Changelog:
[General] [Added] - Fixes SectionList Unmounting issue with separatorComponent on data addition and removal.

Pull Request resolved: https://github.com/facebook/react-native/pull/43223

Test Plan:
i used the `rn-tester` App to test out the changes below is the code to test the same.
Update the snapshots to align with the changes.

```
import React, {useEffect, useState} from 'react';
import {
  StyleSheet,
  Text,
  View,
  SafeAreaView,
  StatusBar,
  SectionList,
  Image,
} from 'react-native';

interface Item {
  id: string;
  title: string;
  imgSrc: string;
}

interface Section {
  title: string;
  data: Item[];
}

const keyExtractor = (item: Item, index: number) => `${item.title}-${index}`;

const renderItem = ({item, index}: {item: Item; index: number}) => {
  return <ItemComponent item={item} index={index} />;
};

const additionalFruits = [
  {
    id: '7',
    title: 'Sandwich',
    imgSrc:
      'https://img.freepik.com/premium-vector/sanwich-vector-isolated-fast-food_484148-2.jpg',
  },
  {
    id: '8',
    title: 'Burger',
    imgSrc:
      'https://static.vecteezy.com/system/resources/thumbnails/033/494/666/original/animated-illustration-of-burger-cartoon-for-foods-menu-animation-free-video.jpg',
  },
  {
    id: '9',
    title: 'Juice',
    imgSrc:
      'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQHg9yLXE7Jlq4OM9ey64TW4D9qUFaeGU76rg&usqp=CAU',
  },
  {
    id: '10',
    title: 'Milkshake',
    imgSrc:
      'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcROpBez3eZKvEVdxBce9XyG6j6caDFMjV_xUQ&usqp=CAU',
  },
];
const DATA: Section[] = [
  {
    title: 'Items',
    data: [
      {
        id: '1',
        title: 'Cake',
        imgSrc:
          'https://static.vecteezy.com/system/resources/previews/012/132/227/original/cute-cake-cartoon-icon-illustration-food-recreation-icon-concept-isolated-premium-flat-cartoon-style-vector.jpg',
      },
      {
        id: '2',
        title: 'Pizza',
        imgSrc:
          'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2kYjlsayzKZx4hFo6fbH7S8pde2JRo2a0hfaeoz3O7bjqdJjhI0tFiSROM8G4UbdbwXU&usqp=CAU',
      },
      {
        id: '3',
        title: 'Coke',
        imgSrc:
          'https://png.pngtree.com/png-clipart/20220116/original/pngtree-cartoon-hand-painted-coke-bottle-png-image_7106844.png',
      },
      {
        id: '4',
        title: 'Noodles',
        imgSrc:
          'https://thumbs.dreamstime.com/z/cute-cartoon-vector-bowl-noodle-isolated-white-background-115120959.jpg',
      },
      {
        id: '5',
        title: 'Pasta',
        imgSrc:
          'https://t4.ftcdn.net/jpg/02/65/00/69/360_F_265006936_2dlz2VtcqZZUbco1VnDpU2diyd8OagFS.jpg',
      },
      {
        id: '6',
        title: 'Fries',
        imgSrc:
          'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxISEBUQEBAVFRMTERkVFRISDw8PEBIVFRcWFhcSFRYYHSggGBolGxgVITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OGxAQGismICYwLS4vLS0tLS0tLTUvLS0tLS0tLS0vLS0tLS0tLy0tLS0tLS0tLS0tLS0tLS0tLS0tLf/AABEIAOMA3gMBIgACEQEDEQH/xAAcAAEAAgMBAQEAAAAAAAAAAAAABQYCBAcDAQj/xABEEAACAQIBBwgEDAUEAwAAAAAAAQIDEQQFEiExQVGRBhMiYXGBscFSkqHRBxcjMkJygrLC0uHwJDNiY6IUNFPxFU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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf/Z',
      },
    ],
  },
];

const ItemComponent = ({item, index}: {item: Item; index: number}) => {
  useEffect(() => {
    console.log('Mount of', index, item.title);
    return () => {
      console.log('Unmount of', index, item.title);
    };
  }, []);

  return (
    <View style={styles.card}>
      <Text style={styles.cardText}>{item.title}</Text>
      <Image source={{uri: item.imgSrc}} style={styles.imageStyles} />
    </View>
  );
};

const App = () => {
  const [data, setData] = useState(DATA);
  const fetchNextPage = () => {
    const newInnerData = [...data[0].data, ...additionalFruits];
    setData([{...data[0], data: newInnerData}]);
  };

  return (
    <SafeAreaView style={styles.container}>
      <View style={styles.scrollView}>
        <SectionList
          keyExtractor={keyExtractor}
          onEndReachedThreshold={0.5}
          onEndReached={fetchNextPage}
          sections={data}
          renderItem={renderItem}
          ItemSeparatorComponent={() => <View style={{height: 16}} />}
          renderSectionHeader={({section}) => (
            <Text style={styles.sectionHeaderText}>{section.title}</Text>
          )}
        />
      </View>
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#F5F5F5',
    paddingTop: StatusBar.currentHeight,
  },
  scrollView: {
    paddingHorizontal: 16,
  },
  card: {
    backgroundColor: '#FFFFFF',
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    gap: 8,
    height: 200,
    padding: 16,
    borderRadius: 8,
    marginBottom: 16,
    borderWidth: 1,
  },
  cardText: {
    fontSize: 30,
  },
  headerText: {
    fontSize: 24,
    textAlign: 'center',
    marginBottom: 12,
  },
  footerText: {
    fontSize: 24,
    textAlign: 'center',
    marginTop: 12,
  },
  sectionHeaderText: {
    backgroundColor: '#FFFFFF',
    fontSize: 24,
    fontWeight: 'bold',
  },
  imageStyles: {
    height: '100%',
    width: 100,
  },
});

export default App;
```

Reviewed By: yungsters

Differential Revision: D54301991

Pulled By: javache

fbshipit-source-id: d2cfafb1b4eb868761d849111b5abb7e9d584a46
2024-02-29 02:38:46 -08:00
Jakub Romanczyk 62c15bacaa fix(virtualized-lists): declare missing react peer dependency (#42947)
Summary:
In setups with `pnpm`  `react-native/virtualized-lists` gets bundled incorrectly because of the following error:

`Module not found: Error: Can't resolve 'react'`

As 'react' is used inside of the package, it should declared explicitly, instead of being a phantom dependency.

## Changelog:

[GENERAL] [FIXED] - Declare missing peer dependency `react`

Pull Request resolved: https://github.com/facebook/react-native/pull/42947

Test Plan: not needed

Reviewed By: NickGerleman

Differential Revision: D53617462

Pulled By: cortinico

fbshipit-source-id: 19a8fed94263646b0af93339d5c014e629dfa6b1
2024-02-10 17:03:15 -08:00