How to animate on new state? - React

How to animate on new state? - React
0

#1

Hello, at the moment, I have an animation which only occurs when the component renders, however, I want to display the animation every time the state changes, so the change of the quote doesn’t seem so abrupt.

You can check my application here http://oxyrus-random-quote.surge.sh/ to see what I’m talking about.

I haven’t been able to find the way to display that animation when I get a new quote, do you have any ideas?

Thanks!


#2

You can use componentDidUpdate (), or you can update the component changing the key prop ( for example the key can be a boolean value and you can toggle the value everytime you need an update ), or maybe you can use react animation


#3

I’ve been trying to use react animation, but I can’t manage to animate on state change, I have been looking for an example but no luck so far.


#4

Have you tried with componentDidUpdate () ?


#5

Hey Oxyrus have you found a solution to that problem of yours? i’m facing the same problem :frowning:


#6

No, I haven’t been able to find a solution.