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.

play value from useAnimate cannot be use in useEffect

See original GitHub issue

Describe 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:closed
  • Created 4 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
marcin-pielacommented, Jul 4, 2019

I will do, but give me time until tomorrow 😃

1reaction
marcin-pielacommented, Jul 10, 2019

Thanks, now I can replace react-transition-group with you library (2kB less in build 😄 )

Read more comments on GitHub >

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

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