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.

MotiView blinks on first state change

See original GitHub issue

Hi 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.

https://user-images.githubusercontent.com/77419324/156472693-03ebb961-19d7-4202-af5a-8c3bc3a860d6.MP4

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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
nandorojocommented, Apr 17, 2022

sweet! thanks for the update, and glad it’s useful @alantoa

1reaction
alantoacommented, Apr 17, 2022

Hi, @astware @lklima Upgrade you react-native-reanimated version to v2.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!

Read more comments on GitHub >

github_iconTop 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 >

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