RefreshControl on List doesn't work on iOS
See original GitHub issueWe 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:
- Created 5 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hoekma Example provided in #1720 works fine, cross checked it https://github.com/GeekyAnts/NativeBase/issues/1720#issuecomment-376062502
@EgidioCaprino It is mentioned in Docs, that not to use NativeBase List, instead use FlatList