How do I cancel the renewal immediately?

Viewed 59

I am developing an application on React Native. I created the notification component. I have created two unread and read tabs. Clicking on the notifications is immediately read on the API. OnEndReachedThreshold works automatically when I enter FlatList and there is one item. Idont want this. Let it work if data is greater than 10. I hope you understand. My English is not good, sorry.

Sample line of code

    <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}
    />
1 Answers

It is pretty common problem in RN right now. There are some solutions if you google it. One of the is using 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})
/>

The another one is implementing onScroll by yourself.

Related