-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix refreshing state #6737
Fix refreshing state #6737
Conversation
By analyzing the blame information on this pull request, we identified @janicduplessis to be a potential reviewer. |
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! |
Thanks @cpunion, LGTM |
Add a RNPLAY: https://rnplay.org/apps/_Pb4hA |
This patch brings another problem, when pull down to refresh, the view will shake, because Then DO NOT USE THIS PATCH NOW. |
You can check |
@janicduplessis A example sequence:
If finish an API call after 10ms of pull down:
|
What should happen normally is:
It's important that |
You are right, I did some tests and traced state changes, seems OK. |
b41cc0a
to
d2a29f9
Compare
@cpunion updated the pull request. |
0b9f450
to
f16b614
Compare
@cpunion updated the pull request. |
@cpunion updated the pull request. |
@janicduplessis Can't pass CI, I don't know how to fix it. |
Can you try rebasing on master? The failure seems unrelated. |
When RefreshControl.refreshing change twice in 250ms, it ignores the second changing.
@cpunion updated the pull request. |
@janicduplessis passed. Would be merge? or need improve? |
Looks good, I'll test it and we can get this merged! |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
93b39b7
Summary:When RefreshControl.refreshing change twice within 250ms, it ignores the second changing. **Test plan (required)** ``` refresh () { this.setState({ refreshing: true }) fetch('/api') .then(() => { this.setState({ refreshing: false }) }) .catch((error) => { this.setState({ refreshing: false }) }) } render() { return ( <ScrollView refreshControl={ <RefreshControl refreshing={this.state.refreshing} onRefresh={this.refresh.bind(this)} /> }> <TouchableHighlight onPress={this.refresh.bind(this)}> <View> <Text>Touch Me!</Text> </View> </TouchableHighlight> </ScrollView> ) } ``` * Test Case 1: Touch "Touch Me!", if get response less than 250ms, the state is always refreshing. * Test Case 2: Close network, Touch "Touch Me!", the state is always refreshing. Closes facebook#6737 Differential Revision: D3189627 fb-gh-sync-id: 81c1932408e1ab99732b8340a5e3bd557629a66b fbshipit-source-id: 81c1932408e1ab99732b8340a5e3bd557629a66b
Summary:When RefreshControl.refreshing change twice within 250ms, it ignores the second changing. **Test plan (required)** ``` refresh () { this.setState({ refreshing: true }) fetch('/api') .then(() => { this.setState({ refreshing: false }) }) .catch((error) => { this.setState({ refreshing: false }) }) } render() { return ( <ScrollView refreshControl={ <RefreshControl refreshing={this.state.refreshing} onRefresh={this.refresh.bind(this)} /> }> <TouchableHighlight onPress={this.refresh.bind(this)}> <View> <Text>Touch Me!</Text> </View> </TouchableHighlight> </ScrollView> ) } ``` * Test Case 1: Touch "Touch Me!", if get response less than 250ms, the state is always refreshing. * Test Case 2: Close network, Touch "Touch Me!", the state is always refreshing. Closes facebook#6737 Differential Revision: D3189627 fb-gh-sync-id: 81c1932408e1ab99732b8340a5e3bd557629a66b fbshipit-source-id: 81c1932408e1ab99732b8340a5e3bd557629a66b
When RefreshControl.refreshing change twice within 250ms, it ignores the second changing.
Test plan (required)