Skip to content
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

RefreshControl issue:open and close at once #13554

Closed
fiattt opened this issue Apr 18, 2017 · 3 comments
Closed

RefreshControl issue:open and close at once #13554

fiattt opened this issue Apr 18, 2017 · 3 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@fiattt
Copy link

fiattt commented Apr 18, 2017

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. second time the
spinner will open and close at once.
seem the same with:#10373

Reproduction Steps and Sample Code

use the code in: https://facebook.github.io/react-native/docs/refreshcontrol.html and change a bit for sample:

the diff is:
image

the whole file:listTestPage.js.zip

the Reproduction gif:
bug

'use strict';

const React = require('react');
const ReactNative = require('react-native');
const {
    ScrollView,
    StyleSheet,
    RefreshControl,
    Text,
    TouchableWithoutFeedback,
    View,
} = ReactNative;

const styles = StyleSheet.create({
    row: {
        borderColor: 'grey',
        borderWidth: 1,
        padding: 20,
        backgroundColor: '#3a5795',
        margin: 5,
    },
    text: {
        alignSelf: 'center',
        color: '#fff',
    },
    scrollview: {
        flex: 1,
    },
});

class Row extends React.Component {
    _onClick = () => {
        this.props.onClick(this.props.data);
    };

    render() {
        return (
            <TouchableWithoutFeedback onPress={this._onClick} >
                <View style={styles.row}>
                    <Text style={styles.text}>
                        {this.props.data.text + ' (' + this.props.data.clicks + ' clicks)'}
                    </Text>
                </View>
            </TouchableWithoutFeedback>
        );
    }
}

class listTestPage extends React.Component {
    static title = '<RefreshControl>';
    static description = 'Adds pull-to-refresh support to a scrollview.';

    state = {
        isRefreshing: false,
        loaded: 0,
        rowData: Array.from(new Array(20)).map(
            (val, i) => ({text: 'Initial row ' + i, clicks: 0})),
    };

    _onClick = (row) => {
        row.clicks++;
        this.setState({
            rowData: this.state.rowData,
            isRefreshing: true,
        });

        setTimeout(()=>{
            this.setState({
                isRefreshing: false,
            });
        },2000);
    };

    render() {
        const rows = this.state.rowData.map((row, ii) => {
            return <Row key={ii} data={row} onClick={this._onClick}/>;
        });
        return (
            <ScrollView
                style={styles.scrollview}
                refreshControl={
          <RefreshControl
            refreshing={this.state.isRefreshing}
            onRefresh={this._onRefresh}
            tintColor="#ff0000"
            title="Loading..."
            titleColor="#00ff00"
            colors={['#ff0000', '#00ff00', '#0000ff']}
            progressBackgroundColor="#ffff00"
          />
        }>
                {rows}
            </ScrollView>
        );
    }

    _onRefresh = () => {
        this.setState({isRefreshing: true});
        setTimeout(() => {
            // prepend 10 items
            const rowData = Array.from(new Array(10))
                .map((val, i) => ({
                    text: 'Loaded row ' + (+this.state.loaded + i),
                    clicks: 0,
                }))
                .concat(this.state.rowData);

            this.setState({
                loaded: this.state.loaded + 10,
                isRefreshing: false,
                rowData: rowData,
            });
        }, 5000);
    };
}

module.exports = listTestPage;

Additional Information

  • React Native version: 0.41.1
  • Platform: iOS
  • Development Operating System: MacOS
  • Dev tools: Xcode 8.3
@fiattt fiattt changed the title RefreshControl issue RefreshControl issue:open and close at once Apr 18, 2017
@hramos hramos added the Icebox label Jul 31, 2017
@hramos
Copy link
Contributor

hramos commented Jul 31, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos closed this as completed Jul 31, 2017
@ghost
Copy link

ghost commented Aug 28, 2017

+1

@bdrobinson
Copy link

I'm still finding this to be an issue on 0.48.3.

@facebook facebook locked as resolved and limited conversation to collaborators Jul 31, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants