You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you pass TRUE to the RefreshControl 'refreshing' prop, the component will open and show the spinner until it receives a FALSE value. However, this only happens the first time. Any subsequent 'refreshing' state changes won't open the component on TRUE but once it becomes FALSE, the component will open and close at once.
I realize that the RefreshControl may not have been designed to use it this way but the fact that it behaves differently the first time vs. any other time, would indicate a bug.
Steps to Reproduce / Code Snippets
Setup a ListView or ScrollView with a RefreshControl (default refreshing to false). Add a means of changing the 'refreshing' state (button for example). Once clicked, you'll notice the RefreshControl open up until the state is set to FALSE. If you repeat the same process, you will get a different behavior where it open and closes when 'refreshing' is set to FALSE.
Sample code:
'use strict';importReact,{Component}from'react';import{View,StyleSheet,Text,Image,ListView,RefreshControl,Dimensions,TouchableOpacity,}from'react-native';exportdefaultclassFeedItemListViewextendsComponent{constructor(props){super(props);this.state={loading: false}this.toggleLoadingState=this.toggleLoadingState.bind(this);this.triggerLoadingState=this.triggerLoadingState.bind(this);this.refreshItems=this.refreshItems.bind(this);}refreshItems(){this.setState({loading: true});// Do some heavy lifting...setTimeout(()=>{this.setState({loading: false})},3000);}triggerLoadingState(){this.refreshItems();}renderFeedItem(){return(<Viewstyle={{flex:1,height:200,marginBottom:5,backgroundColor:'#ececec',alignItems:'center',justifyContent:'center'}}><Text>ITEM</Text></View>)}render(){letds=newListView.DataSource({rowHasChanged: (r1,r2)=>r1!==r2});letitems=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];letlistView=(<Viewstyle={{flex:1,marginTop:30}}><TouchableOpacityonPress={this.triggerLoadingState}><Text>Toggle loading state: {this.state.loading}</Text></TouchableOpacity><ListViewref="feedItemsList"style={styles.itemList}dataSource={ds.cloneWithRows(items)}renderRow={this.renderFeedItem}refreshControl={<RefreshControlref="rc"style={{backgroundColor:'transparent'}}refreshing={this.state.loading}onRefresh={this.refreshItems}/>}enableEmptySections={true}indicatorStyle={"black"}/></View>);returnlistView;};};conststyles=StyleSheet.create({container : {flex:1},});
Expected Results
I would expect the RefreshControl to behave the same way every time I change the 'refreshing' state (same behavior as first state change).
Additional Information
There is a way to work around this for the time being. If you over-scroll your ListView (to about y=-60 in iOS) you will trigger the RefreshControl as if it were triggered by a user interaction. Its just not the cleanest way.
React Native version: 0.31
Platform(s) (iOS, Android, or both?): iOS
Operating System (macOS, Linux, or Windows?): macOS
The text was updated successfully, but these errors were encountered:
I think something else is the problem here. RefreshControl does work with setting the refreshing state from false -> true -> false -> true a number of times - you can see this in action in UIExplorer, like the example on https://facebook.github.io/react-native/docs/refreshcontrol.html . One possible problem is that there is a race condition in your code here - the setTimeout could be returning after several cycles of toggling the refresh behavior. If you are still running into an issue here then I would suggest asking on Stack Overflow or trying to restart this component from something functional like the example. I am going to close this issue but if I am missing something about how to repro this bug then please feel free to reopen.
Issue Description
If you pass TRUE to the RefreshControl 'refreshing' prop, the component will open and show the spinner until it receives a FALSE value. However, this only happens the first time. Any subsequent 'refreshing' state changes won't open the component on TRUE but once it becomes FALSE, the component will open and close at once.
I realize that the RefreshControl may not have been designed to use it this way but the fact that it behaves differently the first time vs. any other time, would indicate a bug.
Steps to Reproduce / Code Snippets
Setup a ListView or ScrollView with a RefreshControl (default refreshing to false). Add a means of changing the 'refreshing' state (button for example). Once clicked, you'll notice the RefreshControl open up until the state is set to FALSE. If you repeat the same process, you will get a different behavior where it open and closes when 'refreshing' is set to FALSE.
Sample code:
Expected Results
I would expect the RefreshControl to behave the same way every time I change the 'refreshing' state (same behavior as first state change).
Additional Information
There is a way to work around this for the time being. If you over-scroll your ListView (to about y=-60 in iOS) you will trigger the RefreshControl as if it were triggered by a user interaction. Its just not the cleanest way.
The text was updated successfully, but these errors were encountered: