Closed Chatharaju closed 5 years ago
Please provide a proper runnable repro as per the issue template
Please have a look at the .gif.
Please post your code
there you go. I cannot put the original code but pretty much mocked it.
You're passing inline functions to SceneMap
. The docs explicitly say not to do that.
https://github.com/react-native-community/react-native-tab-view#renderscene-required
Current behaviour
My tab view renders a scrollview and mapping a list. When I navigate to a different screen by clicking one of the item, when I navigating back the list automatically goes to the top. Happens only in Android
Expected behaviour
The list should not scroll to top.
Screenshots (if applicable)
Code sample
<TabView navigationState={this.state} renderScene={SceneMap({ current: () => <FlatList data={[{ key: 'a' }, { key: 'b' }, { key: 'c' }, { key: 'd' }, { key: 'e' }, { key: 'f' }, { key: 'g' }, { key: 'h' }, { key: 'i' }, { key: 'j' }, { key: 'k' }, { key: 'l' }, { key: 'm' }, { key: 'n' }, { key: 'o' }, { key: 'p' }, { key: 'q' }, { key: 'R' }]} renderItem={({ item }) => <TouchableOpacity onPress={(props) => onItemPress(props)}> <View style={{ borderWidth: 1 }}> <Text style={{ fontSize: 20, marginBottom: 30 }}>{item.key} } />, past: () => <FlatList data={[{ key: 'a' }, { key: 'b' }, { key: 'c' }, { key: 'd' }, { key: 'e' }, { key: 'f' }, { key: 'g' }, { key: 'h' }, { key: 'i' }, { key: 'j' }, { key: 'k' }, { key: 'l' }, { key: 'm' }, { key: 'n' }, { key: 'o' }, { key: 'p' }, { key: 'q' }, { key: 'R' }]} renderItem={({ item }) => <TouchableOpacity onPress={(props) => onItemPress(props)}> <View style={{ borderWidth: 1 }}> <Text style={{ fontSize: 20, marginBottom: 30 }}>{item.key} } /> />, })} onIndexChange={index => this.setState({ index })} initialLayout={styles.tabSize} renderTabBar={props => <TabBar {...props} getLabelText={({ route }) => route.title} activeColor={Primary.Black} inactiveColor={conGray} indicatorStyle={styles.tabIndicator} style={styles.tabs} labelStyle={styles.labelStyle} /> } />
const styles = StyleSheet.create({ main: { flex: 1, backgroundColor: "#f8f8f8", paddingTop: 6 }, content: { marginBottom: 100 }, noMsg: { marginTop: 50, textAlign: 'center' }, loading: { flex: 1, flexDirection: 'column', justifyContent: 'center', alignItems: 'stretch', } })