Flatlist not supported for RTL

See original GitHub issue

<Flatlist> horizontal true component does not work properly on Rtl devices, it renders the items again and jumps to head of list. impossible to use

Environment

Environment: OS: macOS High Sierra 10.13.4 Node: 8.2.1 Yarn: 1.3.2 npm: 5.5.1 Watchman: 4.7.0 Xcode: Xcode 9.3 Build version 9E145 Android Studio: 3.1 AI-173.4670197

Packages: (wanted => installed) react: 16.3.2 => 16.3.2 react-native: 0.55.0 => 0.55.0

Steps to Reproduce

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  FlatList,
  I18nManager
} from 'react-native';

const getList = () => {
  let list = []
  for (i=0;i<100;i++)
    list.push({title:i,backgroundColor:getRandomColor()})
  return list
}

export default class AutoLinkDemo extends Component {
  constructor(props){
    super(props)
    this.state={
      data:getList()
    }
  }
  render() {
    return (
      <View style={styles.container}>
      <Text style={{fontWeight:'bold',fontSize:60}}>{`is RTL? ${I18nManager.isRTL}`}</Text>
      <View style={styles.list}>
        <FlatList 
          data={this.state.data}
          contentContainerStyle={{alignItems:'center', justifyContent:'center'}}
          renderItem={({ item }) => this.renderCardItem(item)}
          keyExtractor={(item, index) => index}
          horizontal
        />
      </View>
      </View>
    )
  }
  renderCardItem(item){
    return(
      <View style={[styles.cardItem,{backgroundColor:item.backgroundColor}]}>
        <Text style={{fontWeight:'bold',fontSize:40}}>{item.title}</Text>
      </View>
    )
  }
}

function getRandomColor() {
  var letters = '0123456789ABCDEF';
  var color = '#';
  for (var i = 0; i < 6; i++) {
    color += letters[Math.floor(Math.random() * 16)];
  }
  return color;
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#F5FCFF',
    alignItems:'center', justifyContent:'center',
  },
  list: {
    height:250,
    backgroundColor: 'yellow',
    alignItems:'center', justifyContent:'center',
  },
  cardItem:{
    height:200,
    width:250,
    alignItems:'center',
    justifyContent:'center',
    margin:5,
  },
});

AppRegistry.registerComponent('AutoLinkDemo', () => AutoLinkDemo);

Expected Behavior

<Flat list should adopt to relevant direction as I18nManager.isRtl` returns

Actual Behavior

<Flatlist> horizontal true component does not work properly on Rtl devices, it renders the items again and jumps to head of list. impossible to use

if i add attribute legacyImplementation={true} it works fine but as said in documents i doent know what traits of Flatlist i loose.

rtl1 rtl

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:8
  • Comments:63 (11 by maintainers)

github_iconTop GitHub Comments

14reactions
mm7modcommented, Nov 29, 2020

30 years later : hey react native the issue still exits any luck , it has been open for 30 years now

14reactions
ENateghcommented, Jan 14, 2020

adding inverted={true} just worked for me: <FlatList inverted={true} horizontal={true} />

Read more comments on GitHub >

github_iconTop Results From Across the Web

react native flat list horizontal RTL auto scroll issue
Hi, you can check my solution. Here is how i created my RTL friendly Flatlist component github.com/facebook/react-native/issues/… – Ozan ...
Read more >
React-Native FlatList issues in RTL view : r/reactnative - Reddit
I have a Horizontal FlatList and in RTL view the FlatList just constantly call onEndReached method but that's not the case in LTR...
Read more >
Layout Props - React Native
When direction is rtl , borderEndWidth is equivalent to borderLeftWidth . ... Ems and other units are not supported.
Read more >
Horizontal FlatList RTL - Expo Snack
Bug onReachedEnd called multiple times on a horizontal Flatlist with Right to Left set to true.
Read more >
scrollToIndex is not working in RTL FlatList React-Native ...
Coding example for the question scrollToIndex is not working in RTL FlatList React-Native-React Native.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found