question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing style values from regular to Animated.Value removes view for several frames

See original GitHub issue

Description

If you have an Animated.View with regular width: 100 style values and want to change it to an Animated.Value instance width: new Animated.Value(100), it removes the view completely from view hierarchy for several frames and mounts again.

Reproducing example

https://snack.expo.io/@terrysahaidak/reanimated-removes-view-bug

Video

https://drive.google.com/file/d/1HIfFt9vWX23lcnZukQSlw1n15-1ZWzcw/view?usp=drivesdk

Explanation

Why you ever want to change some values from animated one to regular? The case I was playing with is lazy value initializations. Since creating a lot of Animated.Value blocks the js thread (see #194) and I have a lot of them on the same screen, I do not initialize them until I start the animation by some event (for example, pressing the button or focusing the input).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:23 (14 by maintainers)

github_iconTop GitHub Comments

3reactions
chrfalchcommented, Jul 9, 2019

I’ve investigated this issue and I think I have found the problem.

First of all - this is NOT an Android problem - this is happens on iOS as well (change title, @terrysahaidak ?), it just happens so quickly that it is hard to see it 😃

The problem is evident if you attach a spy function to the message queue and is mostly visible for width/height/flex style properties (or style properties that forces a layout update).

The view is not recreated as we first assumed.

The issue is that when you update the styles the view will receive a call to update its properties through the UIManager updateView function - and the property value for the width/height/flex prop has a null value since the reanimated node has not yet been created. Creating the node happens after the call to updateView, and from there on everything is good.

I’m investigating the possibilities for a fix and will come back 😃

1reaction
MasterLambastercommented, Jul 15, 2020

Is there any updates on this? This is still an issue and makes impossible to have any components that have any animated initial state along side with regular styling.

Read more comments on GitHub >

github_iconTop Results From Across the Web

6: Animations with Animated.Value - React Native Animations
Let's see a simple example animation with Animated. Value ------------Don't forget to subscribe and like the video if you enjoyed :)Be a ...
Read more >
Using CSS animations - CSS: Cascading Style Sheets | MDN
The CSS animation longhand properties can accept multiple values, separated by commas. This feature can be used when you want to apply multiple...
Read more >
Property Animation Overview | Android Developers
A property animation changes a property's (a field in an object) value over a specified length of time. To animate something, you specify ......
Read more >
Controlling CSS Animations and Transitions with JavaScript
Transitions in CSS are applied to an element and specify that when a property changes it should do so over gradually over over...
Read more >
Animating Views and Transitions — SwiftUI Tutorials
When using SwiftUI, you can individually animate changes to views, or to a ... you'll import and model hiking data, and then add...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found