简体   繁体   English

Flatlist反向不适用于React Native

[英]Flatlist inverted is not working on React Native

The following is my code for the flatlist 以下是我的清单的代码

render() {
   console.log("chatthread --",this.props.chatThreadStore.getchatThreads);
   const { navigate } = this.props.navigation;
   return (
        <View style={ChatThreadStyle.container}>
            <FlatList
                data={this.props.chatThreadStore.getchatThreads}
                renderItem={({ item,index }) => this.renderFlatList(Object.keys(item).toString(),Object.values(item).toString())}
                keyExtractor={(item, index) => index}
                inverted={true}   
            />
        </View>
    );
}

renderFlatList(time,message) {
    console.log("time--",time);
    unixTime=convertFireBaseTimeToUnix(time);
return (
        <ListItem
            hideChevron={true}
            containerStyle={{ borderTopWidth: 0, borderBottomWidth: 0 }}
            title={<View>
                <View style={ChatThreadStyle.containerText}>
                    <Text style={ChatThreadStyle.textContent}>{moment.unix(unixTime).format('lll')}</Text>
                </View>
                <View style={ChatThreadStyle.titleContainer} >
                    <Text style={ChatThreadStyle.titleStyle}>{message}</Text>
                </View>
            </View>
            }


        />
    )
}

The following is the data which is passing to the FlatList 以下是传递到FlatList的数据

Array [
  Object {
    "1509964621958": "Hey! the Good the bad and the ugly",
  },
  Object {
    "1509964820253": "The prisoners 2010",
  },
  Object {
    "1509965207453": "The Rocky!!",
  },
]

My list are not invertet. 我的清单不是invertet。 I get the same output when I use inverted={true} flag or when I omit inverted flag. 当我使用反向= {true}标志或省略反向标志时,我会得到相同的输出。

use only inverted, inverted = {true} is bad! 仅使用倒置,倒置= {true}不好! Something like this: 像这样:

<FlatList
    inverted         
    data={this.props.chatThreadStore.getchatThreads}

/>

我相信,在本机版本0.47之后添加反向道具,请尝试升级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM