<bdo id='vXijJ'></bdo><ul id='vXijJ'></ul>
<legend id='vXijJ'><style id='vXijJ'><dir id='vXijJ'><q id='vXijJ'></q></dir></style></legend>
    1. <small id='vXijJ'></small><noframes id='vXijJ'>

        <tfoot id='vXijJ'></tfoot>
        <i id='vXijJ'><tr id='vXijJ'><dt id='vXijJ'><q id='vXijJ'><span id='vXijJ'><b id='vXijJ'><form id='vXijJ'><ins id='vXijJ'></ins><ul id='vXijJ'></ul><sub id='vXijJ'></sub></form><legend id='vXijJ'></legend><bdo id='vXijJ'><pre id='vXijJ'><center id='vXijJ'></center></pre></bdo></b><th id='vXijJ'></th></span></q></dt></tr></i><div id='vXijJ'><tfoot id='vXijJ'></tfoot><dl id='vXijJ'><fieldset id='vXijJ'></fieldset></dl></div>
      1. 实现拉取刷新 FlatList

        时间:2023-11-29
          <tbody id='ZQr7F'></tbody>

        <small id='ZQr7F'></small><noframes id='ZQr7F'>

          • <tfoot id='ZQr7F'></tfoot>

                <bdo id='ZQr7F'></bdo><ul id='ZQr7F'></ul>
                <i id='ZQr7F'><tr id='ZQr7F'><dt id='ZQr7F'><q id='ZQr7F'><span id='ZQr7F'><b id='ZQr7F'><form id='ZQr7F'><ins id='ZQr7F'></ins><ul id='ZQr7F'></ul><sub id='ZQr7F'></sub></form><legend id='ZQr7F'></legend><bdo id='ZQr7F'><pre id='ZQr7F'><center id='ZQr7F'></center></pre></bdo></b><th id='ZQr7F'></th></span></q></dt></tr></i><div id='ZQr7F'><tfoot id='ZQr7F'></tfoot><dl id='ZQr7F'><fieldset id='ZQr7F'></fieldset></dl></div>

                <legend id='ZQr7F'><style id='ZQr7F'><dir id='ZQr7F'><q id='ZQr7F'></q></dir></style></legend>
                1. 本文介绍了实现拉取刷新 FlatList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  请帮助我在我的应用程序上实现拉动刷新,我对本机反应有点新,谢谢.我不知道如何处理onRefresh和刷新.

                  please help me out to implement pull to refresh on my app, I'm kinda new to react native, thanks. I don't know how to handle onRefresh and refreshing.

                  class HomeScreen extends Component {
                    state = { refreshing: false }
                  
                    _renderItem = ({ item }) => <ImageGrid item={item} />
                  
                    _handleRefresh = () => {
                  
                    };
                  
                    render() {
                      const { data } = this.props;
                      if (data.loading) {
                        return (
                          <Root>
                            <Loading size="large" />
                          </Root>
                        )
                      }
                   return (
                     <Root>
                       <HomeHeader />
                       <FlatList
                         contentContainerStyle={{ alignSelf: 'stretch' }}
                         data={data.getPosts}
                         keyExtractor={item => item._id}
                         renderItem={this._renderItem}
                         numColumns={3}
                         refreshing={this.state.refreshing}
                         onRefresh={this._handleRefresh}
                       />
                     </Root>
                    );
                   }
                  }
                  
                  export default graphql(GET_POSTS_QUERY)(HomeScreen);
                  

                  推荐答案

                  设置变量

                  this.state = { 
                      isFetching: false,
                  }
                  

                  创建刷新函数

                  onRefresh() {
                      this.setState({isFetching: true,},() => {this.getApiData();});
                  }
                  

                  最后设置onRefresh并在FlatList中刷新.

                  And in last set onRefresh and refreshing in FlatList.

                  <FlatList
                      data={ this.state.FlatListItems }
                      onRefresh={() => this.onRefresh()}
                      refreshing={this.state.isFetching}
                  />
                  

                  在getApiData函数中获取数据后确保设置false isFetching.

                  After fetching Data in function getApiData Make sure to set false isFetching.

                  this.setState({ isFetching: false })
                  

                  这篇关于实现拉取刷新 FlatList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在堆栈导航器中隐藏标题 React 导航 下一篇:React Native - 导航问题“未定义不是对象(this.props.navigation.navigate)&

                  相关文章

                    <bdo id='EFu16'></bdo><ul id='EFu16'></ul>

                  <tfoot id='EFu16'></tfoot>
                    1. <legend id='EFu16'><style id='EFu16'><dir id='EFu16'><q id='EFu16'></q></dir></style></legend>
                    2. <small id='EFu16'></small><noframes id='EFu16'>

                    3. <i id='EFu16'><tr id='EFu16'><dt id='EFu16'><q id='EFu16'><span id='EFu16'><b id='EFu16'><form id='EFu16'><ins id='EFu16'></ins><ul id='EFu16'></ul><sub id='EFu16'></sub></form><legend id='EFu16'></legend><bdo id='EFu16'><pre id='EFu16'><center id='EFu16'></center></pre></bdo></b><th id='EFu16'></th></span></q></dt></tr></i><div id='EFu16'><tfoot id='EFu16'></tfoot><dl id='EFu16'><fieldset id='EFu16'></fieldset></dl></div>