-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Closed
Labels
BugComponent: FlatListHelp Wanted
Issues ideal for external contributors.Issues ideal for external contributors.Priority: Mid

Description
- Review the documentation: https://facebook.github.io/react-native
- Search for existing issues: https://github.com/facebook/react-native/issues
- Use the latest React Native release: https://github.com/facebook/react-native/releases
Environment
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.5
CPU: x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 25.63 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.11.2 - /usr/local/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 5.6.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
IDEs:
Android Studio: 3.1 AI-173.4819257
Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
npmPackages:
react: 16.3.1 => 16.3.1
react-native: 0.56.0 => 0.56.0
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-scripts: 1.14.0
Description
FlatList
has item with TouchableHighlight
, and a RefreshControl
attached.
onPress
method of TouchableHighlight
is not working the first time after onRefresh
called.
If I scroll FlatList
a bit after refreshed, then item onPress
works fine.
// UPDATE: Android does not have this bug.
Reproducible Demo
Fresh project created by react-native init
import React, { Component } from "react";
import { Text, View, FlatList, TouchableOpacity, RefreshControl } from "react-native";
type Props = {};
export default class App extends Component<Props> {
constructor() {
super();
this.state = { refreshing: true, items: [] };
}
componentDidMount() {
this.refresh();
}
genItems = () => [0, 1, 2, 3, 4, 5];
refresh = () => {
this.setState({ refreshing: true, items: [] });
setTimeout(() => this.setState({ refreshing: false, items: this.genItems() }), 1500);
};
renderItem = ({ item }) => {
const text = `${item}`;
return (
<TouchableOpacity onPress={() => alert("pressed!")}>
<Text style={{ width: "100%", height: 48, backgroundColor: "white" }}>
{text}
</Text>
<View style={{ width: "100%", height: 1, backgroundColor: "gray" }} />
</TouchableOpacity>
);
};
render() {
return (
<View style={{ flex: 1, padding: 48 }}>
<FlatList style={{ flex: 1, backgroundColor: "#aaa", borderColor: "gray", borderWidth: 1 }}
renderItem={this.renderItem}
data={this.state.items}
keyExtractor={item => `${item}`}
refreshControl={
<RefreshControl
refreshing={this.state.refreshing}
onRefresh={this.refresh}
/>
}
/>
</View>
);
}
}
rayhk6, jsdai123, ImagineZzf, dgruseck, charsea and 15 more
Metadata
Metadata
Assignees
Labels
BugComponent: FlatListHelp Wanted
Issues ideal for external contributors.Issues ideal for external contributors.Priority: Mid
