Skip to content
This repository was archived by the owner on Nov 12, 2024. It is now read-only.
Discussion options

You must be logged in to vote

Yeah, this is actually possible with AnimatePresence itself and the usePresence hook.

<AnimatePresence>
  {isVisible && <MyComponent />}
</AnimatePresence>
function MyComponent() {
  const ref= useRef(null)
  const [isPresent, safeToRemove] = usePresence()
  
  useEffect(() => {
    animate(ref.current, { opacity: isPresent ? 1 : 0 }).finished.then(safeToRemove)
  }, [isPresent])

  return <div ref={ref} />
}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@cakir-enes
Comment options

@TommySorensen
Comment options

Answer selected by cakir-enes
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants