Repository navigation
Closed
Labels
Resolution: LockedThis issue was locked by the bot.
Description
this code works perfectly on react native 0.35 or earlier, but after update to react native 0.36 and 0.37 it not works
class LoginViewComponent extends Component {
constructor(props) {
super(props);
this.state = {
scale: new Animated.Value(1.5),
offset: new Animated.Value((window.height / 2) - (125)),
opacity: new Animated.Value(0)
};
}
componentDidMount() {
setTimeout(() => {
Animated.timing(
this.state.offset,
{
toValue: 0,
duration: 1000
}
).start();
Animated.timing(
this.state.scale,
{
toValue: 1,
duration: 1000
}
).start();
setTimeout(() => {
console.log("it is really called");
Animated.timing(
this.state.opacity,
{
toValue: 1,
duration: 500
}
).start();
}, 800);
}, 1200);
}
render() {
var scale = this.state.scale;
return (
<View style={styles.container}>
{/* this animated view works */}
<Animated.View style={[{ alignItems: 'center', position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 }, { transform: [{ scale }, { translateY: this.state.offset }] }]}>
<Image source={require('../Assets/Images/logotype.png')} style={styles.imageLogo} />
</Animated.View>
{/* this animated view do not works */}
<Animated.View style={{ opacity: this.state.opacity }}>
<FinalView />
</Animated.View>
{/* I have tried too */}
<Animated.View style={{ opacity: 1 }}>
<FinalView />
</Animated.View>
</View>
)
}
}
It only works if I remove Animated.View, but works without animation
Metadata
Metadata
Assignees
Labels
Resolution: LockedThis issue was locked by the bot.
Activity
[-]add style opacity to animated.view in react native 0.37[/-][+]Error adding opacity to animated.view in react native 0.37[/+]ericvicenti commentedon Nov 14, 2016
Is this on iOS, Android, or both?
koraniar commentedon Nov 15, 2016
@ericvicenti only on Android, on ios the styles of
<FinalView />are a bit differentcentaurreader commentedon Nov 15, 2016
I am running into the same issue on iOS
ericvicenti commentedon Nov 15, 2016
cc @janicduplessis @ryangomba
centaurreader commentedon Nov 15, 2016
Oops. Sorry I figured it out. I had some bad styles after updating. :(
ericvicenti commentedon Nov 15, 2016
Ok so this may still be Android only. @koraniar, can you provide a simple example of this bug on rnplay.org ?
janicduplessis commentedon Nov 15, 2016
@koraniar What exactly happens when it does not work? Is there an error or just no animation? Could you also provide a small example that reproduces the issue?
koraniar commentedon Nov 15, 2016
@ericvicenti @janicduplessis this is the example https://rnplay.org/apps/u0mzZw (it works well, in my phone the form does not works) , the animation just no works even when i set opacity in 1
<Animated.View style={{ opacity: 1 }}> <FinalView /> </Animated.View>I am testing on a Nexus 5x with Android 7.0
ryangomba commentedon Nov 15, 2016
I'm confused -- rnplay example seems to work for me?
tuckerconnelly commentedon Nov 17, 2016
Yeah I'm running in to this to--
Animated.Views aren't visible on Android when settingstyle.opacity.It won't happen on rnplay because Exponent uses 0.36, not 0.37
Edit: Though it's happening for me on a vanilla react-native app with 0.36 🤔
Hmm, looks like any
Viewwith opacity isn't working.tuckerconnelly commentedon Nov 17, 2016
Got it--I think it has to do with
position: relativeandposition: absolute: https://rnplay.org/apps/bOo6GwHere's a repo to play with: https://github.com/tuckerconnelly/RNAndroidOpacityBug
LoopIndigo commentedon Jan 25, 2017
This seems to still be happening in 0.40 (can anyone else confirm?). In my case I use an interpolated
Animated.Valueto set my opacity. The initial value doesn't seem to work. Once it is changed viaAnimated.timingthe opacity starts working again.Has this been fixed for anyone else?
EDIT: My issue was actually caused by the bug resolved in #11770.
hramos commentedon Jul 20, 2017
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!
If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.
dnaploszek commentedon Dec 22, 2017
Hi,
There is still something wrong with setting opacity as an AnimatedValue:
And then on render:
When i remove opacity: this.state.opacityValue or set it to a constant value (1), the view is rendered otherwise i get this cryptic error:

This error is only reproduced on Android i confirmed that on IOS everything works fine.
I had this error on react-native 0.51.0
EDIT
I dug a bit deeper, and it seems that there is a problem with translating styles on Android:
I'm trying to locate the exact error and will post the results.
hramos commentedon Dec 22, 2017
Please open a new issue.