Commit Graph

21 Commits

Author SHA1 Message Date
Alex Hunt 35f6ed1146 Update SectionList to accept React elements for separators (#53599)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53599

Runtime and types fix for the `ItemSeparatorComponent` prop on `virtualized-list` components (`FlatList`, `SectionList`, `VirtualizedList`).

- Docs source, where this prop (adjacent to other `*Component` props) is documented as accepting elements: https://reactnative.dev/docs/virtualizedlist#itemseparatorcomponent.
- Existing runtime behaviour matching this definition: https://github.com/facebook/react-native/blob/8d33e1c205b12fe27f4319e6566bb0c088197810/packages/virtualized-lists/Lists/VirtualizedListCellRenderer.js#L197-L203

**Changes**

- Update Flow, manual TS type defs.
- Align runtime behaviour in `VirtualizedSectionList` to add matching `React.isValidElement()` behaviour.

Resolves https://github.com/facebook/react-native/issues/53531.

Changelog:
[General][Fixed] - The `ItemSeparatorComponent` prop on list components now accepts a React element as well as a component function.

Reviewed By: cortinico

Differential Revision: D81675423

fbshipit-source-id: 3eed93b1bea89554988d6e20fa61b72e17be55df
2025-09-12 07:54:04 -07:00
Tim Yung ebe2a857f1 RN: Prefer Destructured Import for isValidElement (#51413)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51413

Prefers using this as a destructured import instead of as a member expression of `React`.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D74895841

fbshipit-source-id: c1d3af40134a3721c9a7b676ee1f2c4a18612e4d
2025-05-16 16:33:18 -07:00
Jakub Piasecki f622923374 Update VirtualizedLists react-native imports (#50551)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50551

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D72634484

fbshipit-source-id: 128c4eb1b8d7ca2f3821d138afb6750c19bc5f84
2025-04-14 10:32:48 -07:00
Jakub Piasecki ebbb241bf8 Align layout event names with OSS (#49423)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49423

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D69655570

fbshipit-source-id: bd9b3dbc70b93c5be49e6a2b1b0487d11bf5b3f1
2025-02-18 07:26:13 -08:00
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
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
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 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
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 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 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
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
Pieter De Baets 050a5a3797 Fix CellRenderer onCellFocusCapture not being stable (#41381)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41381

Noticed that when scrolling VirtualizedList's CellRenderer was re-rendering due to `onCellFocusCapture` not having a stable identify. Change the interface to CellRenderer to pass in the `cellKey` in the callback to save on creating new callbacks.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D51112928

fbshipit-source-id: 3fcb974d9b5585403895746fbc45f2cf5a9fa6b1
2023-11-08 15:16:54 -08:00
Moti Zilberman d6e0bc714a Enable lint/sort-imports everywhere (#41334)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41334

TSIA.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D51025812

fbshipit-source-id: e10d437be775a6b80946483aa96460f34927f870
2023-11-06 12:59:38 -08:00
George Zahariev e2116d277d Codemod $Shape to Partial in xplat, suppressing errors [4] (#36960)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36960

We're deprecating the unsafe `$Shape` and moving to the safe `Partial`: https://fb.workplace.com/groups/flowlang/posts/1251655088773485

I have previously codemodded all locations that do not cause errors. Now start on the remaining ones: codemod and suppress.

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D45076273

fbshipit-source-id: 27ebf33370143e19751dbdcfcc1876cf3c586e14
2023-04-18 13:49:07 -07:00
Nick Gerleman 2d41e6642e Fix types + documentation for CellRendererComponent
Summary:
CellRendererComponent can be given a more useful description, and more constrained type, to ensure it is used more correctly.

Changelog:
[General][Fixed] - Fix types + documentation for CellRendererComponent

Reviewed By: yungsters

Differential Revision: D43925572

fbshipit-source-id: 26aae6a2df989993c97709ffbf1544df7cbae036
2023-03-14 15:32:05 -07:00
Nick Gerleman 0daf83ac51 Reconnect VirtualizedList Source History 2/2 (Apply D41745930 + history, D42805202, D43063551)
Summary:
This change re-applies D41745930 (https://github.com/facebook/react-native/commit/2e3dbe9c2fbff52448e2d5a7c1e4c96b1016cf25) (and D42805202 (https://github.com/facebook/react-native/commit/1479b2ac26fded3840c596f53e6eb86a4b0c2c71) which was also partially reverted), re-registers additions as moves, then applies D43063551 which has been added to the changes since migration.

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D43068114

fbshipit-source-id: 72997700bf9962d82a988599481e255b69e68a9b
2023-02-06 20:00:19 -08:00
Nick Gerleman ebaa00e327 Reconnect VirtualizedList Source History 1/2 (Revert D41745930)
Summary:
This change reverts D41745930 (https://github.com/facebook/react-native/commit/2e3dbe9c2fbff52448e2d5a7c1e4c96b1016cf25) as part of a stack to splice back source history which was lost (Git registered the file moves as additions).

It is expected this diff will individually fail. The entire stack should be applied at once.

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D43068113

fbshipit-source-id: c8398629fe5dcc1ca4bf02f550adc00c78a8487a
2023-02-06 20:00:19 -08:00
Gabriel Donadel Dall'Agnol 2e3dbe9c2f feat: Move virtualized lists to @react-native/virtualized-lists (#35406)
Summary:
This PR moves `VirtualizedList`, `VirtualizedSectionList`, and its files to a separate package called `react-native/virtualized-lists` located under `packages/virtualized-lists` as proposed on https://github.com/facebook/react-native/issues/35263

## Changelog

[General] [Changed] - Move virtualized lists to react-native/virtualized-lists package

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

Test Plan:
1. Open the RNTester app and navigate to `FlatList` or `SectionList` page
2. Test virtualized lists through the many sections

https://user-images.githubusercontent.com/11707729/202878843-2b1322f5-cfee-484e-aaf3-d8d4dc0b96cc.mov

Reviewed By: cipolleschi

Differential Revision: D41745930

Pulled By: hoxyq

fbshipit-source-id: d3d33896801fd69448c6893b86fd5c2363144fd0
2023-02-06 13:39:13 -08:00