Git Product home page Git Product logo

rn-activityindicator-bugreport's Introduction

RN-ActivityIndicator-BugReport

Sample App for a bug report for React Native

(Update) Workaround

It seems like a bug with zIndex. As janicduplessis suggested, I added collapsable={false} to the parent View and it worked. The fixed implementation is available under index.android.fixed.js.

The problem

I put an ActivityIndicator on screen, which should be removed after some time (i.e. when the data arrives). But the problem is that it still remains on screen even after it is removed (or not outputted) in the render function. In addition, the backgroundColor of the View above disappears, too.

I also found out that doing one of the following fixes the problem, but I don't know why:

  • Unset the zIndex for the View above (having zIndex here has no reason what so ever, but I needed this in the project I was working on)
  • Set a backgroundColor for the View element containing this ActivityIndicator.

Inline code:

export default class TestReport extends Component {
    state = {
        showIndicator: true,
    };

    componentDidMount() {
        setTimeout(() => this.setState({showIndicator: false}), 3000);
    }

    render() {
        return (
            <View style={styles.container}>
                <View style={styles.firstHalf}>
                </View>
                <View style={styles.secondHalf}>
                    {this.state.showIndicator
                        ? (<ActivityIndicator size="large"/>)
                        : (<Text>hello</Text>)}
                </View>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
    },
    firstHalf: {
        zIndex: 1,
        flex: 1,
        backgroundColor: "#2f2",
    },
    secondHalf: {
        flex: 1,
    },
});

Here's a screen recording of what happens:

  • What should happen: the indicator should be removed after 3 seconds and the message hello should appear.
  • What happens: the indicator remains after the 3 seconds, and the message hello appears. In addition, the backgroundColor of the View above disappears. rn-activityindicator

Versions:

  • react-native: 0.41.2
  • react: 15.4.2
  • react-native-cli: 2.0.1
  • devices:
    • Nexus 5 - Android version: 7.1
    • LG G2 mini - Android version: 5.0.2

rn-activityindicator-bugreport's People

Contributors

farzadab avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.