How to set Refresh Indicator of FlatList in react native?

后端 未结 2 415
名媛妹妹
名媛妹妹 2021-01-04 07:44

I\'m trying to set the refresh indicator of flat list in react native but don\'t know how to do it. List View has this prop :

refreshControl={

        
相关标签:
2条回答
  • 2021-01-04 08:27

    You can pass in the renderScrollComponent to your FlatList component with the same RefreshControl component you have showed above. I have created a expo snack for this: https://snack.expo.io/rJ7a6BCvW

    The FlatList is using VirtualizedList within itself, and for VirtualizedList component, it takes a renderScrollComponent: https://facebook.github.io/react-native/docs/virtualizedlist.html#renderscrollcomponent

    0 讨论(0)
  • 2021-01-04 08:35

    I found the solution! It might be the dummy but FlatList also has a prop called refreshControl like ListView but I just didn't test it! Just like this:

     <FlatList
        refreshControl={<RefreshControl
                        colors={["#9Bd35A", "#689F38"]}
                        refreshing={this.props.refreshing}
                        onRefresh={this._onRefresh.bind(this)} />}
     />
    
    0 讨论(0)
提交回复
热议问题