react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[ActivityIndicator][Android] Indicator stays hidden if initialized as animating={false}

Open kulmajaba opened this issue 10 years ago • 33 comments

Originally discovered on http://stackoverflow.com/questions/38579665/reactnative-activityindicator-not-showing-when-animating-property-initiate-false

If ActivityIndicator is initialized with animating={false}, the Indicator will stay hidden even when changing animating to true. When initialized as animating the changes behave as expected.

Tested on Android emulator and Device, running Android 6.0 and 6.0.1. Also tested on iOS device which works as expected. Testing done with Windows 8.1.

'use strict'

import React, { Component } from 'react';
import {
    AppRegistry,
    Text,
    View,
    TouchableHighlight,
    ActivityIndicator
} from 'react-native';

class SampleApp extends Component {
    constructor() {
        super();

    this.state = {
            show: false
        };
    }

    render() {
        return (
            <View>
                <TouchableHighlight onPress={ () => this.setState({show: false}) } >
                    <Text>HIDE</Text>
                </TouchableHighlight>

                <TouchableHighlight onPress={ () => {this.setState({show: true}) } >
                    <Text>SHOW</Text>
                </TouchableHighlight>

                <ActivityIndicator animating={this.state.show} size="large"/>
            </View>
        );
    }
}

AppRegistry.registerComponent('SampleApp', () => SampleApp);

kulmajaba avatar Jul 26 '16 10:07 kulmajaba

@kulmajaba Which react-native version are you using ? I got the same issue on Android with react-native 0.28. Seems to be a bug with the animating property. Currently using the walkaround of either rendering the ActivityIndicator or completely hide it based on the state

alannesta avatar Jul 31 '16 20:07 alannesta

@alannesta Using React Native 0.30. I've used the same workaround, rendering a separate loading view when needed.

kulmajaba avatar Aug 01 '16 05:08 kulmajaba

I have the opposite bug: it sometimes freezes instead of hiding

antoinerousseau avatar Aug 05 '16 19:08 antoinerousseau

Same issue on React Native 0.32 on Android 6.0.1

ActivityIndicator did not work so I went back to AndroidProgressBar which had yellow box warning under 0.32 for manually calling a React.PropTypes validation function.

ActivityIndicator work-around was to use null when animating should be false

                  let spinner = (this.state.animate) ? (
                    <ActivityIndicator
                    animating={true}
                    size="small"
                    />
                  ) : (
                      null
                  );

esutton avatar Aug 30 '16 14:08 esutton

@facebook-github-bot label Icebox

charpeni avatar Nov 14 '16 03:11 charpeni

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/activityindicatorandroid-indicator-stays-hidden-if-initialized-as-animatingfalse

ProductPains helps the community prioritize the most important issues thanks to its voting feature. It is easy to use - just login with GitHub.

Also, if this issue is a bug, please consider sending a PR with a fix. We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.

charpeni avatar Nov 14 '16 03:11 charpeni

@facebook-github-bot close

charpeni avatar Nov 14 '16 03:11 charpeni

@charpeni tells me to close this issue. If you think it should still be opened let us know why.

facebook-github-bot avatar Nov 14 '16 03:11 facebook-github-bot

Is this fixed? Is there any workaround? The productpains post doesn't have any updates.

prithsharma avatar Dec 29 '16 21:12 prithsharma

I'm still having this error on RN 0.40

fcpauldiaz avatar Feb 03 '17 17:02 fcpauldiaz

The simplest I did was

<ActivityIndicator
   animating={true}
   style = {{ opacity : this.state.animate ? 1 : 0 }}
/>

raphkr avatar Feb 21 '17 18:02 raphkr

@raphkr i don't like that at all... Then it's always animating... not the best

Brian-Kaplan avatar Feb 22 '17 21:02 Brian-Kaplan

I'm seeing this bug on Android too (Android 7.1 emulator). The opacity: 0 solution from this post worked for me:

http://stackoverflow.com/questions/38579665/reactnative-activityindicator-not-showing-when-animating-property-initiate-false

I think this issue needs to be reopened.

sryze avatar Mar 03 '17 11:03 sryze

This one is simple and background is not clickable when loading. Manage the loading icon using this.state.loading

{ this.state.loading &&
     <View style={styles.loading}>
          <ActivityIndicator
                 animating = {true}
                 color = '#bc2b78'
                 size = "large"/>
     </View>
}

and in styles

loading: {
    position: 'absolute',
    left: 0,
    right: 0,
    top: 0,
    bottom: 0,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#F5FCFF88'
  }

mirzavu avatar Sep 15 '17 06:09 mirzavu

Can confirm this is still happening in Android RN: 0.51.0. I'm using a conditional JSX expression as a workaround but strange this hasn't been fixed yet. Why was this closed at all if it's still an issue that needs to be addressed?

Dror-Bar avatar Jan 10 '18 11:01 Dror-Bar

+1 I have the same problem

alexsmartens avatar Feb 19 '18 20:02 alexsmartens

Let's reopen it then.

charpeni avatar Feb 19 '18 20:02 charpeni

Did anyone find the solution? I am also stuck at the same problem.

changulpaye avatar Mar 09 '18 12:03 changulpaye

@changulpaye

<ActivityIndicator
   animating={true}
   style = {{ opacity : this.state.animate ? 1 : 0 }}
/>

fcpauldiaz avatar Mar 10 '18 01:03 fcpauldiaz

This is still happening in 0.54.4.

ocarreterom avatar Apr 05 '18 15:04 ocarreterom