React-native: layoutanimation on android not work

Created on 12 Jan 2016  路  14Comments  路  Source: facebook/react-native

layoutanimation on android not work

Locked

Most helpful comment

@JasonScopServ Hey I usually put it to the constructor:

import {UIManager} from 'react-native';

constructor() {
    super();

    if (Platform.OS === 'android') {
      UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);
    }
  }

All 14 comments

Hey nowaits, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!
UIManager.setLayoutAnimationEnabledExperimental &&   UIManager.setLayoutAnimationEnabledExperimental(true);

to enable LayoutAnimation on Android

This should be documented in LayoutAnimation.

+1 @amiuhle

This SHOULD be documented in LayoutAnimation!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Where do I put this code?

@JasonScopServ Hey I usually put it to the constructor:

import {UIManager} from 'react-native';

constructor() {
    super();

    if (Platform.OS === 'android') {
      UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);
    }
  }

This should really be documented, broke my head over this.

@janmarsicek Super helpful. I also wanted to ask is it possible to add the code somewhere else? I'm using react-native-stage-0 so I am just initializing state without constructor method.

Hi @jasan-s! According the docs it should be ok to set the following flags like in the example in https://github.com/facebook/react-native/blob/master/docs/Animations.md#layoutanimation-api Sorry I don't have time to check if it works...

One more thing to import Platform.
import { Platform } from 'react-native';

still not getting this to work with an actual animation, whether i set the flag in the app.js file or ini a component directly.

I manage to fix this issue. You guy can take a look in here

Could anyone answer:
If we use LayoutAnimation in several components - should we call
UIManager.setLayoutAnimationEnabledExperimental(true)
in each component, or we can just call it once?
Thanks

Was this page helpful?
0 / 5 - 0 ratings