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

How to use Animated in Custom Component #13914

Closed
Symous opened this issue May 11, 2017 · 2 comments
Closed

How to use Animated in Custom Component #13914

Symous opened this issue May 11, 2017 · 2 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@Symous
Copy link

Symous commented May 11, 2017

I create a Custome Component With these props:

opacity: PropTypes.number, // opacity;

In one page I use this to make it support animate.

const AnimatedProgress = Animated.createAnimatedComponent(RecorderProgress);

then , I set a percentage state.

this.state= { _opacity: new Animated.Value(0)}

and set a animate in componentDidMount;

Animated.timing(this.state._opacity,{
      toValue:1,  // no-transparent;
      duration:5000
    }).start();

add the component to page:

<AnimatedProgress  opacity={opacity:this.state._opacity}/>

But when I run the app, there is no animation of the component.

I also found that if I create a opacity in style of the component directly, the animation works.

<AnimatedProgress  style={{opacity:this.state._opacity}}/>

Please it's very confused me, is there any one who can help me?Thanks.

@jaygarcia
Copy link
Contributor

This type of question is best posted in Stack Overflow.

This book by @browniefed is a really good start.

http://browniefed.com/react-native-animation-book/API.html

@Symous
Copy link
Author

Symous commented May 12, 2017

I have fixed that which is due to add a setNativeProps(props) method to the custom component.I remove the method and it works as excepted now.

@Symous Symous closed this as completed May 12, 2017
@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 18, 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

3 participants