play value from useAnimate cannot be use in useEffect
See original GitHub issueDescribe the bug
Value of play
is changing during the animation and it cannot be used inside useEffect
To Reproduce
I want to play animation depends on isOpened
prop from parent and I need value of isPlaying
to conditionally show children
(I think that is not doable using Animation component)
const { play, style, isPlaying } = useAnimate({
start: { opacity: 0 },
end: { opacity: 1 },
play: isOpened,
});
useEffect(() => {
play(isOpened)
}, [isOpened, play]);
return (isOpened || isPlaying) ? children : null;
Above code produces infinite loop inside useEffect.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
play value from useAnimate cannot be use in useEffect #52
Describe the bug Value of play is changing during the animation and it cannot be used inside useEffect To Reproduce I want to...
Read more >Need to access useState value within a useEffect, but cant put ...
I have a socket emitting from the server that sends a +1 or -1. The socket.on must be in a useEffect or else...
Read more >React.useEffect Hook – Common Problems and How to Fix ...
The first and probably most obvious option is to remove the dependency from the useEffect dependency array, ignore the ESLint rule, and move...
Read more >react-animatable - npm
Pass the return value of useAnimation to ref of element you want to control. Call play() ! import { useEffect } from "react"; ......
Read more >Animations in threejs, help needed to create a simpler ...
I am working on a small animation-helper for a tool that i make, gltfjsx. Currently it extracts animations by creating a new mixer, ......
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
I will do, but give me time until tomorrow 😃
Thanks, now I can replace react-transition-group with you library (2kB less in build 😄 )