Граф коммитов

173 Коммитов

Автор SHA1 Сообщение Дата
David Vacca 8eeb01686f Ship virtualizedlist remeasure fix
Summary:
This diff ships the virtualizedlist remeasure fix implemented in D27003249 (1bc06f18c6)

For more details about experiment see: https://fb.workplace.com/groups/rn.engineering/permalink/2831770330485832/

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28072308

fbshipit-source-id: c23c958ca9f2991236cb5a5c02084722aa6de919
2021-04-28 20:16:23 -07:00
Luna Wei bac2c2c801 Update FlowFixMes to use error codes in react-native-github
Summary:
Changelog:
[Internal] - Add error codes to existing FlowFixMe's

Reviewed By: kacieb

Differential Revision: D27445689

fbshipit-source-id: 2b19692e1cb822ab6785efcc5f93ee33e7dce1e5
2021-03-31 18:21:47 -07:00
Luna Wei 321de15803 Delete unused FlowFixMes in xplat/js/react-native-github
Summary:
Changelog:
[Internal] - Remove unused FlowFixMes

Reviewed By: kacieb

Differential Revision: D27445690

fbshipit-source-id: c1fbf4495ae020b30a458c2ef4870547fd5d5c6e
2021-03-31 18:21:47 -07:00
Luna Wei 5475f29554 Reland stack for removing defaultProps from VL and remove breaking FlowFixMe
Summary:
Changelog:
[Internal][Changed] - Remove keyExtractor from defaultProps as part of larger effort to remove defaultProps from VirtualizedList

[General][Changed] - Remove data as a prop for VirtualizedSectionList. In the reactnative.dev docs it mentions that sections is the equivalent for *SectionList: https://reactnative.dev/docs/sectionlist#sections

[General][Changed] - Change export type of VirtualizedSectionList and wrap component updates in act in test.

[Internal] - Remove FlowFixMe from VirtualizedSectionList

Reviewed By: kacieb

Differential Revision: D27271493

fbshipit-source-id: f83bdcce9c71c140c8a8fb6f0ecd9bb520fcb85b
2021-03-25 13:00:28 -07:00
Jimmy Zhang f293d41ead Back out "Update typed export and fix test", Back out "[VirtualizedSectionList] Remove defaultProps", Back out "[VirtualizedList] Remove keyExtractor defaultProps"
Summary:
Changelog:
Partial revert the stack

Reviewed By: makovkastar

Differential Revision: D27156625

fbshipit-source-id: b158c9102047bb64ce708b200a8e5786f5a0c176
2021-03-18 07:42:41 -07:00
Luna Wei 1cbedb95ec Remove keyExtractor defaultProps
Summary:
Changelog:
[Internal][Changed] -Remove keyExtractor from defaultProps as part of larger effort to remove defaultProps from VirtualizedList

Reviewed By: nadiia

Differential Revision: D26969588

fbshipit-source-id: b00922a339cbe471fcbf560ab4abdd9e48eda1fc
2021-03-17 12:50:23 -07:00
Luna Wei 76b6a66f4f Remove updateCellsBatchingPeriod defaultProps
Summary:
Changelog:
[Internal][Changed] -Remove updateCellsBatchingPeriod from defaultProps as part of larger effort to remove defaultProps from VirtualizedList

Reviewed By: nadiia

Differential Revision: D26969581

fbshipit-source-id: b1d1d18d575d9a6af2e68fe564d221849094f26b
2021-03-17 12:50:23 -07:00
Luna Wei b3101457a6 Remove windowSize defaultProps
Summary:
Changelog:
[Internal][Changed] -Remove windowSize from defaultProps as part of larger effort to remove defaultProps from VirtualizedList

Reviewed By: nadiia

Differential Revision: D26969589

fbshipit-source-id: da6215ee3876c8f186d59f91ef6fd94396366119
2021-03-17 12:50:23 -07:00
Luna Wei 3c5fa3b642 Remove scrollEventThrottle defaultProps
Summary:
Changelog:
[Internal][Changed] -Remove scrollEventThrottle from defaultProps as part of larger effort to remove defaultProps from VirtualizedList

Reviewed By: nadiia

Differential Revision: D26969580

fbshipit-source-id: 504e11493113c01d70e77b90f96c6506c179c060
2021-03-17 12:50:23 -07:00
Luna Wei e3c3ef0ace Remove onEndReachedThreshold defaultProps
Summary:
Changelog:
[Internal][Changed] -Remove onEndReachedThreshold from defaultProps as part of larger effort to remove defaultProps from VirtualizedList

Reviewed By: nadiia

Differential Revision: D26969584

fbshipit-source-id: 03968c5831587f9ed60dc52c55c55c0980f20cbd
2021-03-17 12:50:22 -07:00
Luna Wei 69030a480c Remove maxToRenderPerBatch defaultProps
Summary:
Changelog:
[Internal][Changed] -Remove maxToRenderPerBatch from defaultProps as part of larger effort to remove defaultProps from VirtualizedList

Reviewed By: nadiia

Differential Revision: D26969582

fbshipit-source-id: 64a07aae11f0403b01c01896b4f83565da6ecf43
2021-03-17 12:50:22 -07:00
Luna Wei 529fbc84d5 ESM-ify VirtualizeUtils and flatten parameters on computeWindowedRenderLimits
Summary:
Changelog:
[General][Changed] - Change VirtualizeUtils to use ESM and change function signature on `computeWindowedRenderLimits` as part of larger effort to remove defaultProps from VirtualizedList

Reviewed By: nadiia

Differential Revision: D26969586

fbshipit-source-id: cd1961a2088d37543dbc9bca8c4a062cdb426a35
2021-03-16 21:30:25 -07:00
Luna Wei e928f54d76 Remove initialNumToRender defaultProps
Summary:
Changelog:
[Internal][Changed] - Remove initialNumToRender from defaultProps as part of larger effort to remove defaultProps from VirtualizedList

Reviewed By: nadiia

Differential Revision: D26969585

fbshipit-source-id: 8674544c06b7b99eee693cc7508c9e4199232e98
2021-03-16 21:30:24 -07:00
Luna Wei cbc3d90fd4 Remove horizontal from defaultProps
Summary:
Changelog:
[Internal][Changed] - Remove horizontal from defaultProps as part of larger effort to remove defaultProps from VirtualizedList

Reviewed By: nadiia

Differential Revision: D26969583

fbshipit-source-id: c21ac15a220a68a58e32b78dcc37c053756b72cf
2021-03-16 15:00:49 -07:00
Luna Wei 3ff7e86b0f Remove disableVirtualization from defaultProps
Summary:
Changelog:
[Internal][Changed] - Remove disableVirtualization from defaultProps as part of larger effort to remove defaultProps from VirtualizedList

Reviewed By: nadiia

Differential Revision: D26969587

fbshipit-source-id: 662fa620bc5b6b9a64c1906f62dae1f4b373a23b
2021-03-16 01:49:42 -07:00
David Vacca 1bc06f18c6 Fix impression logging in VirtualizedList
Summary:
This diff forces a remeasure of the children of VirtualizedLists everytime the VirtualizedList is measured.
The goal is to ensure that nested VirtualizedList has the correct "scroll information" all the time, scroll information information is used by ViewabilityHelper.computeViewableItems method to determine if Items of the list are visible to the user.

This new code is controlled by the MC: rn_core:enable_virtualizedlist_remeasure_children_if_needed.

changelog: [internal] internal

// I used an internal changelog because this is under a MC

Reviewed By: lunaleaps

Differential Revision: D27003249

fbshipit-source-id: f9452ceb27683b0f595dd4bffdcced0ecf6bb0b5
2021-03-12 15:33:51 -08:00
David Biedenbach 310a6bcf4b Fix Issue 10718: Add iOS support for progressViewOffset (#30737)
Summary:
Fixes https://github.com/facebook/react-native/issues/10718, bringing `progressViewOffset` support to iOS.

Thanks to Taylor123 for the initial PR upon which this fix is based.

## Changelog

[iOS] [Fix] - `progressViewOffset` prop of `RefreshControl` and `VirtualizedList` now works on iOS

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

Test Plan:
Tested with quick-and-dirty sample app.

![progressViewOffset-iOS](https://user-images.githubusercontent.com/1563532/104526540-82fe1d80-55b7-11eb-9f99-e025bedf4874.gif)

## Documentation

The corresponding documentation update PR can be found [here](https://github.com/facebook/react-native-website/pull/2441).

Reviewed By: kacieb

Differential Revision: D26813977

Pulled By: sammy-SC

fbshipit-source-id: 45cc5a647d70e44a29c6391b7586cb41ca011bef
2021-03-11 10:27:25 -08:00
Hans Halverson d477f80113 Deploy Flow v0.146.0
Summary: Changelog: [Internal]

Reviewed By: mroch

Differential Revision: D26835439

fbshipit-source-id: 2607c3185485c8bd2c7e868dd2e3e0c06866f1f9
2021-03-06 11:37:57 -08:00
simek 927573c581 Flow: fix VirtualizedList issues, remove few no longer valid suppressions (#30128)
Summary:
This PR fixes few suppressed Flow issues in `VirtualizedList` component.

I have also removed few no longer valid Flow suppressions in `ActivityIndicator` and `ReactNativeTestTools`.

## Changelog
[General] [Fixed] - Flow: fix few issues in `VirtualizedList`,
[General] [Removed] - Flow: remove few no longer valid suppressions in `ReactNativeTestTools`

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

Test Plan: Successful run of `yarn flow` check.

Reviewed By: kacieb

Differential Revision: D26489398

Pulled By: lunaleaps

fbshipit-source-id: db71d8bfeb3b6dc5a2738a73ac6644aef4a0311b
2021-02-19 14:31:33 -08:00
Micha Reiser 93377ff508 Remove "use strict" directive from ES Modules
Summary:
ES Modules implicitly enable strict mode. Adding the "use strict" directive is, therefore, not required.

This diff removes all "use strict" directives from ES modules.

Changelog:

[Internal]

Reviewed By: motiz88

Differential Revision: D26172715

fbshipit-source-id: 57957bcbb672c4c3e62b1db633cf425c1c9d6430
2021-02-02 11:12:56 -08:00
Kacie Bawiec 46be292f67 Fix nested FlatList not firing onScrollDragEnd and onMomentum methods
Summary:
With nested FlatLists, three methods aren't firing: `onMomentumScrollBegin`, `onMomentumScrollEnd`, and `onScrollDragEnd`. This is because the nested child lists' methods are not being called.

This copies the solution for this from `onScrollBeginDrag` to the other three methods.

Changelog: [Fixed] Fix nested FlatList not firing onScrollDragEnd and onMomentum methods

Reviewed By: nadiia

Differential Revision: D24803418

fbshipit-source-id: 8685b1ab9f1bd5f67a88d93ac5de628d4bd69024
2020-11-10 09:08:07 -08:00
Tim Yung 982272932c RN: Remove `fbjs/warning` Dependency
Summary:
Replaces `fbjs/warning` call sites in React Native with `console.warn`. A few warnings will now log as warnings without the "Warning:" prefix.

Changelog:
[General][Changed] - Some warnings changed to use `console.warn` without the "Warning:" prefix.

Reviewed By: TheSavior, cpojer

Differential Revision: D22445946

fbshipit-source-id: 96b01e1bdee52b89ff3b808bc9d6cd494f6787f5
2020-08-25 14:15:35 -07:00
Albert Sun 10b4b9505a Make onEndReachedThreshold=null match default value if prop not provided
Summary:
This change makes the behavior of providing a null value to onEndReachedThreshold match the behavior of not providing the prop at all.

## Changelog:

[General] [Changed] - Adjusted VirtualizedList's onEndReachedThreshold default value when null is provided

Reviewed By: olegbl

Differential Revision: D22870445

fbshipit-source-id: 29cbf0550702244007689759846ae0356f06b48d
2020-08-05 15:33:57 -07:00
Mark Verlingieri 3346ac7f96 Don't scroll to initial item if ContentOffset is provided
Summary:
The initialScrollIndex in VirtualizedList contains a performance optimization to start rendering the list at the index provided.

ContentOffset does not contain this optimization and there is currently no way to specify the first item in the list to start rendering without contentOffset being ignored.

This change makes it so that if both initialScrollIndex and ContentOffset are provided, the list will start rendering at the initialScrollIndex but ContentOffset will still be used to set the scroll position.

initialScrollIndex functionality will remain the same if ContentOffset is not provided.

Changelog: [Changed] VirtualizedList will use contentOffset for scroll position instead of initialScrollIndex if both are provided

Reviewed By: sahrens

Differential Revision: D21980172

fbshipit-source-id: 36d2d2bc360845ef02329d2b95a2cf14b91c2b0b
2020-06-11 15:44:02 -07:00
Spencer Ahrens 646605b90e update nested VList warning to error
Summary:
This has caused SEVs because the warning has gone unnoticed, so upgrading to error which should be much harder to miss or ignore.

https://fb.workplace.com/groups/rn.core/permalink/2680043542227367/

# Changelog
[Internal] update nested VList warning to error

Reviewed By: TheSavior

Differential Revision: D21945364

fbshipit-source-id: 88a9a9ab0b51e0afcf9b25be9854f65a61f419af
2020-06-09 16:31:28 -07:00
Kacie Bawiec 7f2515ece8 Add warning when scrollRef does not have a scrollTo method
Summary:
Add a `console.warn()` call when calling `_scrollRef.scrollTo`, because `scrollTo` is not guaranteed to exist on `_scrollRef`.

Context:
`VirtualizedList` holds `_scrollRef`, which is usually a reference to a `ScrollView` component. However, there are several cases where it holds a `View` or other type of component instead.

A custom component can be passed in to `renderScrollComponent`, and then `_scrollRef` will point to that custom component. Additionally, if two VirtualizedLists are nested with the same orientation, `_defaultRenderScrollComponent` will return a View instead of a ScrollView.

Due to these possibilities, `_scrollRef` is not guaranteed to have a `scrollTo` method.

Changelog: [General] [Added] - Add warning when scrollRef does not have a scrollTo method

Reviewed By: JoshuaGross, TheSavior

Differential Revision: D21386842

fbshipit-source-id: 01e167e0ae0edea8f29853e8b242ce88a5103b49
2020-05-04 16:42:13 -07:00
Tim Yung ddea7c76b3 VirtualizedList: Remove `PropTypes` Dependency
Summary:
Removes `PropTypes` as a dependency of `VirtualizedList` by no longer validating the return value of `getItemLayout`.

Changelog: [Internal]

Reviewed By: TheSavior, cpojer

Differential Revision: D21370890

fbshipit-source-id: 966db3557b714987aa91179c7654a5ebf27818ad
2020-05-04 01:00:07 -07:00
Tim Yung 7bd694fc6f VirtualizedList: Migrate to React.Context
Summary:
Migrates `VirtualizedList` off legacy context by creating `VirtualizedListContext`.

Changelog:
[General][Changed] - Migrated `virtualizedList` legacy context to `React.Context`.

Reviewed By: TheSavior

Differential Revision: D21370882

fbshipit-source-id: 2fa99ee0bc0e6b747a2d3fe7c66ee402c6b9c5af
2020-05-04 01:00:06 -07:00
Daiki Ihara 78d2b3c813 refine invariant error message at scrollToIndex (#28464)
Summary:
I refined the error message of scrollToIndex.

When I used scrollToIndex with `index:0` and data that length is 0, I met the odd error message `Invariant Violation scrollToIndex out of range: requested index 0 but maximum is -1`.

Next, I thought that scrollToIndex with `index:-1` meant scrollToTop without checking data length. I met `Invariant Violation: scrollToIndex out of range: requested index -1 but maximum is -1`

Finally, I wondered what will happen to use scrollToIndex with `index:-1` and data that length is `5`. The result is `Invariant Violation: scrollToIndex out of range: requested index -1 but maximum is 5`

The above error messages will confuse us. I clarified the boudaries and separated the error messages

## Changelog

[General] [Fixed] - Clarified the boundaries in error message of scrollToIndex
Pull Request resolved: https://github.com/facebook/react-native/pull/28464

Test Plan:
I added 3 test cases to cover the new error messages for VirtualizedList.
Run `yarn test` and confirm it passes.

Reviewed By: cpojer

Differential Revision: D21140133

Pulled By: TheSavior

fbshipit-source-id: 9a7a704f7ec599d833d2ed3ca2be059d950539b5
2020-04-28 19:15:05 -07:00
George Zahariev cd347a7e0e Upgrade Prettier in Xplat to version 1.19.1
Summary:
Upgrades Prettier in Xplat to 1.19.1
Ignores upgrading packages on already on versions greater than 1.19.1

Changelog: [Internal]

allow-large-files
bypass-lint

(Note: this ignores all push blocking failures!)

Reviewed By: gkz, cpojer

Differential Revision: D20879147

fbshipit-source-id: 0deee7ac941e91e1c3c3a1e7d3d3ed20de1d657d
2020-04-09 11:01:58 -07:00
Martin Sherburn d3658bc2b6 Fix issue with onEndReached
Summary:
onEndReached can be triggered twice when more items are added to the end of the list. This change makes it so that a second call to onEndReached won't happen until the user scrolls down to the new end of the list.

Changelog:

[General] [Fixed] - Fix double call to onEndReached in VirtualizedList

Reviewed By: sahrens

Differential Revision: D20066740

fbshipit-source-id: 129d7ae6bfd241eeea18fe0bb12b82be67735874
2020-03-27 03:58:39 -07:00
Kacie Bawiec d2f314af75 Make ScrollView use ForwardRef
Summary:
Have ScrollView use forwardRef so that the host component methods like `measure` and `measureLayout` are available without having to call `getNativeScrollRef`. Instead, you can use `<ScrollView ref={myRef} />` and directly call all methods of ScrollView and host components on `myRef`.

Previous usage:
```
const myRef = React.createRef<React.ElementRef<typeof ScrollView>>();
<ScrollView ref={myRef} />

const innerViewRef = myRef.current.getNativeScrollRef();

innerViewRef.measure();
```
New usage:
```
const myRef = React.createRef<React.ElementRef<typeof View>>();
<ScrollView ref={myRef} />

// now, myRef.current can be used directly as the ref
myRef.current.measure();
myRef.current.measureLayout();

// Additionally, myRef still has access to ScrollView methods
myRef.current.scrollTo(...);
```

Changes:

* Added deprecation warnings to ScrollView methods `getNativeScrollRef`, `getScrollableNode`, and `getScrollResponder`
* Added the forwardRef call to create `ForwardedScrollView` - this takes in `ref` and passes it into the class ScrollView as `scrollViewRef`.
* Forwarded the ref to the native scroll view using `setAndForwardRef`.
* Added statics onto `ForwardedScrollView` so that `ScrollView.Context` can still be accessed.
* Added type `ScrollViewImperativeMethods`, which lists the public methods of ScrollView.
* Converted all public methods of ScrollView to arrow functions. This is because they need to be bound to the forwarded ref.
* Bound all public methods of ScrollView to the forwarded ref in the `setAndForwardRef` call.
* Flow typed the final output (ForwardedScrollView) as an abstract component that takes in the props of the `ScrollView` class, and has all methods of both the inner host component (`measure`, `measureLayout`, etc) and the public methods (`scrollTo`, etc).

Changes to mockScrollView:
* Changed mockScrollView to be able to mock the function component instead of a class component
* Updated necessary tests

Changelog:
[General] [Changed] - Make ScrollView use forwardRef

Reviewed By: TheSavior

Differential Revision: D19304480

fbshipit-source-id: 6c359897526d9d5ac6bc6ab6d5f9d82bfc0d8af4
2020-03-26 16:53:46 -07:00
Michael Bolin 0b9ea60b4f Back out "Upgrade Prettier from 1.17 to 2.0.2."
Differential Revision: D20639755

fbshipit-source-id: 5028563f9cf0527a30b4259daac50cdc03934bfd
2020-03-24 21:47:35 -07:00
Michael Bolin cf44650b3f Upgrade Prettier from 1.17 to 2.0.2.
Summary:
This gets us on the latest Prettier 2.x:
https://prettier.io/blog/2020/03/21/2.0.0.html

Notably, this adds support for TypeScript 3.8,
which introduces new syntax, such as `import type`.

Reviewed By: zertosh

Differential Revision: D20636268

fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
2020-03-24 20:24:47 -07:00
Logan Daniels 074a2fab74 Update measurements for Footer in VirtualizedList when the footer's onLayout is called
Summary:
When any list cell that may contain nested VirtualizedLists is laid out, it's possible that the offset of any child lists relative to the outermost list has changed. We need to tell these children to re-measure themselves relative to that outermost list, so that their viewability calculations are correct.

We already do this for regular list cells -- we just need to extend that logic to any child lists that may live in the ListFooterComponent.

Changelog: [General] [Fixed] - Fix viewability calculations for nested VirtualizedLists inside of a parent list's FooterComponent

Differential Revision: D20310961

fbshipit-source-id: 4bfcfb95c87329f2ee337d5499e5c7162ba692e8
2020-03-06 15:51:33 -08:00
Rachel Nabors c0d8c1db90 Updating the URLs to point at new domain name reactnative.dev
Summary:
We recently updated React Native's docs site to have its own domain reactnative.dev and needed to update the URLs in the source code

CHANGELOG:
[INTERNAL]

Reviewed By: hramos

Differential Revision: D20072842

fbshipit-source-id: 1970d9214c872a6e7abf697d99f8f5360b3b308e
2020-02-24 13:09:11 -08:00
Moti Zilberman f7c6066425 Log VirtualizedList nesting hierarchy in listKey collision error
Summary:
## Context

When a `VirtualizedList` contains a cell which itself contains more than one `VirtualizedList` of the same orientation as the parent list, we log an error if sibling lists in a cell don't have unique `listKey`s (e.g. when the `listKey` prop isn't explicitly set). In release builds, this error does not have a component stack - nor a useful call stack - so it can be hard to track down the true source of the error in complex applications.

## This diff

Here, in addition to the generic error message, we also print the `listKey`, `cellKey` and orientation of each `VirtualizedList` in the hierarchy, from the child list upwards. This is done without significant overhead, by reusing the already-in-place context that `VirtualizedList`s use to manage nesting.

The assumption is that common strategies for deriving `listKey`s and `cellKey`s will make it possible to identify at least some lists in the hierarchy in common cases, and therefore help narrow down the search space even when component stacks are not available.

## Example

(See code in unit test)

```
A VirtualizedList contains a cell which itself contains more than one VirtualizedList of the same orientation as the parent list. You must pass a unique listKey prop to each sibling list.

VirtualizedList trace:
  Child (horizontal):
    listKey: level2
    cellKey: cell0
  Parent (horizontal):
    listKey: level1
    cellKey: cell0
  Parent (vertical):
    listKey: level0
    cellKey: rootList
```

Changelog: [Internal]

Reviewed By: TheSavior

Differential Revision: D19600366

fbshipit-source-id: 73f29507ec58a6a3f9b3f6b174a32b21dcd237a1
2020-01-28 11:34:14 -08:00
Spencer Ahrens 8ddf231306 Fix sporadic issue with onEndReached called on load when not needed
Summary:
Fixes https://github.com/facebook/react-native/issues/16067

The issue is due to a race between `onLayout` and `onContentSizeChange`, which in general should be fine because there is no expectation of ordering between the two, and only causes issues with certain configurations.

The bug can be triggered if `initialNumToRender` is smaller than needed to fill past the `onEndReachedThreshold` (say the default, 10, is only 580px tall, but it takes 15 to reach the threshold). This will cause an incrementally render of more items to try and fill the viewport. The problem is that if the `onLayout` comes back before the first `onContentSizeChange`, it will first do the state increment to render 20 items and then the stale `onContentSizeChange` callback from 10 items will fire and we'll think that the content size for 20 items is 580px when in fact it's 1160px (which is past the threshold). If those 20 items are also all of our available data, then we'll call `onEndReached` because we think we've rendered everything and are still within the `onEndReachedThreshold`.

The fundamental problem here is the system getting confused when a stale async `onContentSizeChange` comes in after increasing `state.last`. I wish there was a concrete timeframe, but Fabric will give us more flexibility to do things synchronously so hopefully we can avoid class of issues once that roles out.

The fix here simply adds a check to make sure `contentLength` has been set before adjusting the render window so it's not possible to increase the window size before the initial `onContentSizeChange` callback fires.

For completeness, there are a few user-code workarounds to avoid this issue entirely:

1) Provide the `getItemLayout` prop so the list doesn't have to rely on async layout data (you should do this whenever possible anyway for better perf). e.g. for the original snack example, you can just add `getItemLayout={(d, index) => ({length: 58, offset: 58 * index, index})}` since all the rows are height 58 and the issue will no longer repro. Note this is fragile and must be kept in sync with UI changes, a11y font scaling, etc - a more robust approach could be to render a single representative row offscreen and measure it with `onLayout` then use that value.
2) If `getItemLayout` is not feasible to compute for your UI, increase `initialNumToRender` to cover the `onEndReachedThreshold`.
3) And/or add your own logic to protect against extra calls to `onEndReached` as others have suggested.

Changelog:
[General][Fixed] - Fix sporadic issue with onEndReached called on load when not needed

# Test Plan
Adds a new jest test that fails without this fix and succeeds with it.

Reviewed By: TheSavior

Differential Revision: D18966721

fbshipit-source-id: de05d9f072e24a2faf351e7f5d60578a31def996
2019-12-13 16:09:00 -08:00
Kacie Bawiec bde1d63c85 Add getNativeScrollRef to FlatList
Summary:
Add a method to get the underlying host component of `FlatList`. Fix flow types in `FlatList` and `VirtualizedList`. Add test cases to test the behavior of the new function in all cases.

Changelog: [General] [Added] - Add getNativeScrollRef method to FlatList component

Reviewed By: TheSavior

Differential Revision: D18302202

fbshipit-source-id: 7005a2bc1dab207434be3f1f4d8fde0b11b3bb4d
2019-12-03 10:17:15 -08:00
George Zahariev 8553e1acc4 Exact-by-default codemod for react-native-github
Summary:
We are rolling out exact-by-default syntax to xplat/js.

I had to manually move around some comments to preserve proper placement.

Changelog: [Internal]

Reviewed By: jbrown215

Differential Revision: D18633611

fbshipit-source-id: 48f7468dcc55b1d00985419d035a61c6820b3abe
2019-11-21 09:42:57 -08:00
Jordan Brown 93e58b2c96 Suppressions for 0.111
Summary:
still some generated files in www that need to land before we can release 0.111 here.

drop-conflicts

Changelog: [Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: dsainati1

Differential Revision: D18278838

fbshipit-source-id: b20c3fefb3aab7c5fb614b33d846c7548184f49a
2019-11-05 17:36:23 -08:00
Andres Suarez 3b31e69e28 Tidy up license headers [2/n]
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: yungsters

Differential Revision: D17952694

fbshipit-source-id: 17c87de7ebb271fa2ac8d00af72a4d1addef8bd0
2019-10-16 10:06:34 -07:00
Eli White db84ae8fb3 Improve return type for ScrollView getters
Summary: These types are more accurate

Reviewed By: lunaleaps

Differential Revision: D17862010

fbshipit-source-id: 84dfcade35c21b7be49db46ae021819dda020c98
2019-10-11 11:46:00 -07:00
Eli White 06f32bff82 Improve ScrollView and friends flow types for Props
Summary:
These components had props that were poorly typed and let many things through. This diff tightens that all up.

The main difference in this diff is using `{...BaseProps, ...LocalProps }` instead of `BaseProps & LocalProps`.

The majority of the changes in this diff is reducing duplicated prop definitions. For example, FlatList defines a bunch of props that VirtualizedList also defines. Since FlatList extends those props, using spread now means that FlatList can't duplicate those props. So I've moved the definitions to the correct base file and deleted the duplicates.

Changelog:
[Internal]

Reviewed By: lunaleaps

Differential Revision: D17824459

fbshipit-source-id: 089ac4c58c3c9f70a9f28e517f2e9ecd8aab1a50
2019-10-11 09:49:31 -07:00
Eli White 43ff9da68d VirtualizedList update parentProps.getItemLayout flow type
Summary:
This is a tighter type that matches the actual prop as defined on line 100

Changelog:
[Internal]

Reviewed By: lunaleaps

Differential Revision: D17863133

fbshipit-source-id: 97f966ff13aa2ce36ef936a9a154fdd137191c6b
2019-10-11 09:49:30 -07:00
Eli White 8eea187085 VirtualizedList clean up prop flow definitions and comments
Summary: These comments existed for other components that had these props. Putting them here as this is the proper base of those other components. Also adding `ItemSeparatorComponent` as it is used in this component.

Reviewed By: lunaleaps

Differential Revision: D17860495

fbshipit-source-id: b7b60058d37e90699b28419af27d488bd46d3ebd
2019-10-11 09:49:29 -07:00
Eli White 515cc6f596 Fix some $FlowFixMe in VirtualizedList
Summary:
Fixing up some of the FlowFixMes in VirtualizedList

Changelog:
[Internal]

Reviewed By: zackargyle

Differential Revision: D17839611

fbshipit-source-id: c763a799efca63fd7110cfaed87afde80995b8aa
2019-10-11 09:49:27 -07:00
Mike Vitousek d34bc5fa64 Upgrade to Flow v0.108.0
Reviewed By: gabelevi

Differential Revision: D17488182

fbshipit-source-id: e67c5bcbd9f0bda49d52531387d92d7c83a01f21
2019-09-20 13:37:25 -07:00
Eli White f8e5093823 Improve Flow Type for ScrollResponder
Summary: FlatList and VirtualizedList were typing this value as any instead of using the actual type from ScrollView. I started with that change and then fixed the type to solve the other callsites in the codebase.

Reviewed By: zackargyle

Differential Revision: D17089934

fbshipit-source-id: bfc22cec9993904d779cad37b1de7cb3c0484d2c
2019-08-28 13:15:29 -07:00
Vojtech Novak bef87b648c improve VirtualizedList error message (#25973)
Summary:
Motivation: when you receive error like `scrollToIndex out of range: 5 vs -1` it's not immediately clear if I requested 5 or -1. This will make the error a little easier to understand.

## Changelog

not needed
Pull Request resolved: https://github.com/facebook/react-native/pull/25973

Test Plan: not needed, tests must pass

Differential Revision: D16708522

Pulled By: osdnk

fbshipit-source-id: 8dfcbd95ff0f42805dbe32cd57969a93aea55add
2019-08-12 04:34:25 -07:00