【问题标题】:How do I cancel the renewal immediately?如何立即取消续订?
【发布时间】:2019-11-03 04:49:52
【问题描述】:

我正在 React Native 上开发一个应用程序。我创建了通知组件。我创建了两个未读和已读标签。单击通知会立即在 API 上读取。当我进入 FlatList 并且有一项时,OnEndReachedThreshold 会自动工作。我不想要这个。如果数据大于10就让它工作。希望你理解。我的英语不好,对不起。

示例代码行

    <FlatList
        data={notifyReadData}
        renderItem={({item}) =>
            <ListItem                                    
                title={item.userName}
                subtitle={Moment(item.createdAt, 'YYYY-MM-DD HH:mm:ss', true).add(3, 'hour').format("DD.MM.YYYY HH:mm")}
                leftIcon={<Icon
                    name='bell-o'
                    size={24}
                    color='black'
                />}
                bottomDivider={true}
            />
        }
        keyExtractor={this.keyExtractor}
        refreshing={isRefreshing}
        onRefresh={this.handleRefresh}
        onEndReached={this.handleLoadMore}
        onEndReachedThreshold={0.01}
    />

【问题讨论】:

    标签: javascript reactjs typescript react-native


    【解决方案1】:

    这是目前 RN 中很常见的问题。如果你用谷歌搜索,有一些解决方案。其中之一是使用 onMomentumScrollBegin

    <FlatList
        data={notifyReadData}
        renderItem={({item}) =>
            <ListItem                                    
                title={item.userName}
                subtitle={Moment(item.createdAt, 'YYYY-MM-DD HH:mm:ss', true).add(3, 'hour').format("DD.MM.YYYY HH:mm")}
                leftIcon={<Icon
                    name='bell-o'
                    size={24}
                    color='black'
                />}
                bottomDivider={true}
            />
        }
        keyExtractor={this.keyExtractor}
        refreshing={isRefreshing}
        onRefresh={this.handleRefresh}
        onEndReached={this.state.scrolled && this.handleLoadMore()}
        onEndReachedThreshold={0.01}
        onMomentumScrollBegin={this.setState({scrolled: true})
    />
    

    另一个是自己实现onScroll。

    【讨论】:

    • 谢谢,但没有用。您还有其他建议吗?
    猜你喜欢
    • 1970-01-01
    • 2018-12-14
    • 2011-05-26
    • 1970-01-01
    • 2012-04-08
    • 2017-02-01
    • 2018-12-14
    • 2019-02-05
    • 1970-01-01
    相关资源
    最近更新 更多