mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fixup fbsource for $ArrayLike FlatList data (#37314)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37314 Turns out we never transitioned fbsource to an API change we made for FlatList, due to mismatched `.js` and `.js.flow` files. Inside of RN, `$ArrayLike` in Flow, unlike `ArrayLike` in TypeScript, treats `length` as writable. So we wrap that in `$ReadOnly`. Another option might be to inline our own version, since it is not the only [case where they differ](https://fb.workplace.com/groups/flow/permalink/24328911383397481/). In product code, the changes end up impacting: 1. `getItemLayout` is no longer typed to receive a mutable array. I changed all of the incompatible explicit type parameters from `Array<ItemT>` to `Iterable<ItemT>`. 2. Flow has a harder time inferring destructured `data` in examples that were passing `any` to FlatList, so I needed to give some type hints where `data` was previously untyped 3. Replace some `$FlowFixMe[incompatible-type]` with `$FlowFixMe[incompatible-type-arg]` Changelog: [Internal] Reviewed By: lunaleaps Differential Revision: D45665199 fbshipit-source-id: 59aa908e277a27f7ca88acb48de493d2782517a9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2029688630
commit
ea12c4c3d0
@@ -231,7 +231,7 @@ class NativeCxxModuleExampleExample extends React.Component<{||}, State> {
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
<FlatList
|
||||
// $FlowFixMe[incompatible-type]
|
||||
// $FlowFixMe[incompatible-type-arg]
|
||||
data={Object.keys(this._tests)}
|
||||
keyExtractor={item => item}
|
||||
renderItem={({item}: {item: Examples, ...}) => (
|
||||
|
||||
Reference in New Issue
Block a user