question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RefreshControl on List doesn't work on iOS

See original GitHub issue

We have this Contacts component for displaying a refreshable list of contacts.

import React, { Component } from 'react';
import { RefreshControl } from 'react-native';
import { connect } from 'react-redux';
import { Button, Container, Content, Icon, List, Spinner } from 'native-base';
import PropTypes from 'prop-types';
import { cloneDeep } from 'lodash';
import { fetchAll } from '../../actions/contacts';
import { navigateToConversation } from '../../actions/conversations';
import ContactListItem from './ContactListItem';

class Contacts extends Component {
  static propTypes = {
    contacts: PropTypes.arrayOf(PropTypes.shape({
      id: PropTypes.string.isRequired,
    })).isRequired,
    fetched: PropTypes.bool.isRequired,
    handleConfirm: PropTypes.func.isRequired,
    handleRefresh: PropTypes.func.isRequired,
    refreshing: PropTypes.bool.isRequired,
  };

  constructor(props) {
    super(props);
    this.state = { contacts: cloneDeep(this.props.contacts) };
    this.onSelect = this.onSelect.bind(this);
  }

  onSelect(contactId) {
    const updatedContacts = this.state.contacts.map(contact => (
      contact.id === contactId
        ? { ...contact, selected: !contact.selected }
        : contact
    ));
    this.setState({ contacts: updatedContacts });
  }

  render() {
    const {
      fetched, handleConfirm, handleRefresh, refreshing,
    } = this.props;
    const { contacts } = this.state;
    const selectedContacts = contacts.filter(({ selected }) => selected);
    return (
      <Container>
        <Content>
          {
            selectedContacts.length
              ? (
                <Button onPress={() => handleConfirm(selectedContacts)}>
                  <Icon android="md-exit" ios="ios-exit" name="plane" />
                </Button>
              )
              : null
          }
          {!fetched && refreshing && <Spinner />}
          <List
            dataArray={contacts}
            refreshControl={
              <RefreshControl
                onRefresh={handleRefresh}
                refreshing={refreshing}
              />
            }
            renderRow={contact => (<ContactListItem
              {...contact}
              key={contact.id}
              onPress={() => this.onSelect(contact.id)}
            />)}
          />
        </Content>
      </Container>
    );
  }
}

export default connect(
  state => ({
    contacts: state.contacts.list,
    fetched: state.contacts.fetched,
    refreshing: state.contacts.fetching,
  }),
  dispatch => ({
    handleRefresh: () => dispatch(fetchAll(true)),
    handleConfirm: contacts => dispatch(navigateToConversation(contacts)),
  }),
)(Contacts);

We are able to refresh the list on Android but not on iOS.

node, npm, react-native, react and native-base version

node 10.7.0 yarn 1.7.0 react-native 0.55.4 react 16.3.1 native-base 2.6.1

Expected behaviour

Both on Android and iOS it should trigger the handleRefresh function and displaying the spinner until refreshing becomes false again.

Actual behaviour

It works as expected on Android, but not on iOS.

Steps to reproduce should include code snippet and screenshot

Component above.

Is the bug present in both iOS and Android or in any one of them?

Just iOS.

Any other additional info which would help us debug the issue quicker.

None.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
SupriyaKalghatgicommented, Jul 30, 2018
1reaction
SupriyaKalghatgicommented, Jul 30, 2018

@EgidioCaprino It is mentioned in Docs, that not to use NativeBase List, instead use FlatList

Read more comments on GitHub >

github_iconTop Results From Across the Web

RefreshControl sometimes does not hide and acts weirdly on ...
after upgrading from react-native@0.26 activity indicator of RefreshControl sometimes appears in right corner of ScrollView on iOS.
Read more >
React Native Pull-to-Refresh: Make Refreshing Easy for Users
React Native provides an individual RefreshControl component ... list and its item view, and even see it running on both iOS and Android....
Read more >
Pull to refresh in SwiftUI with refreshable - Sarunw
SwiftUI got a native way to add UIRefreshControl in iOS 15. Let's find out how to add it in the list view and...
Read more >
Pull to Refresh Control and One Time Data Fetch Task in SwiftUI
iOS 15 introduced two new APIs to simplify data load and refresh actions. ... If there is no chance in ids, the list...
Read more >
SwiftUI Pull to Refresh (for iOS 13 and iOS 14) - eppz!
Resolve underlying UIScrollView behind a SwiftUI List. Behind every SwiftUI List there is ... Stop refresh control after async work is done.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found