MotiView blinks on first state change
See original GitHub issueHi Fernando! First of all, great job on this library, I immediately fell in love with it.
I’m having an issue when using transforms on entry animations. When I mount my view it slides from the bottom with a “translateY” transform, and it works perfectly, however, the first time the local state changes, there is a small flicker or blink in the component.
I’ve attached a video showing the issue below.
This is the code
import React, {useState} from 'react'
import {StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import {COLOR_BACKGROUND} from "../config/colors";
import {SPACING} from "../config/layout";
import {MotiView} from 'moti';
import {elevationShadowStyle} from "../helpers/elevationShadowStyle";
const DemoScreen = () =>{
const [value, setValue] = useState(false);
const handlePress = () => {
setValue(true);
};
return <View style={styles.container}>
<TouchableOpacity onPress={handlePress} style={styles.button}>
<Text>Click</Text>
</TouchableOpacity>
<MotiView
from={{
transform: [
{
translateY: 100,
},
],
}}
animate={{
transform: [{ translateY: 0 }],
}}
>
<View style={styles.fixedBottomContainer}>
<Text>I flicker on the first button click.</Text>
</View>
</MotiView>
</View>
};
const styles = StyleSheet.create({
container: {
padding: 20,
backgroundColor: COLOR_BACKGROUND
},
divider: {
marginVertical: 10
},
button: {
backgroundColor: 'red',
padding: SPACING * 2,
marginBottom: SPACING * 3
},
fixedBottomContainer: {
padding: SPACING * 2,
backgroundColor: 'white',
...elevationShadowStyle(20)
}
});
export default DemoScreen;
When “handlePress” is called the first time and “value” gets updated, the flicker happens.
I hope it’s just a mistake in my code.
Greetings from México!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:19 (10 by maintainers)
Top Results From Across the Web
React router native animation blinks before animation starts
I'm developing a react native app and using React router native v4, and I'm trying to develop the animation part, as suggested by...
Read more >Avoid flickering images when state change? : r/reactjs - Reddit
I have a state that is an array of messages. ... It will vanish the flickering! ... The state change is causing the...
Read more >useAnimationState - Moti
When using this hook, your animations are static, meaning they have to be known ahead of time. You can change the state by...
Read more >Hooks / React.useState cause flicker issue when used in ...
Current Behavior v2 - Using hooks along with state within onProgress callback creates a re-render loop. Player flickers endlessly.
Read more >Privacy Policy - Montview Vineyard
Country refers to: Vermont, United States; Device means any device that ... Flash Cookies, please read "Where can I change the settings for ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
sweet! thanks for the update, and glad it’s useful @alantoa
Hi, @astware @lklima Upgrade you
react-native-reanimated
version tov2.5.0+
, will be resolved! You can check out this PR https://github.com/software-mansion/react-native-reanimated/pull/2851.By the way, @nandorojo thanks a lot for your library, Moti let’s write a lot less animation code, It’s grate!