Skip to content
Discussion options

You must be logged in to vote

I found the fix. Triggering the removal on the end of the exit animation fixes it. What i needed to do was not call the remove() function twice (once when the button was clicked and another time when the exit animation triggered).

Instead, I added an isDeleting state variable and set it to true when the button was clicked:

const [isDeleting, setIsDeleting] = useState(false)

function handleDelete() {
    setIsDeleting(true)
  }

<motion.div 
      layout='position'
      variants={blockVariants}
      initial='initial'
      animate={isDeleting ? 'exit' : 'animate'}
      className='rounded-[12px] bg-lighter-blue p-5 border border-blue-border'
      onAnimationComplete={(e) =>  {
        if 

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@kNicu
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by kNicu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants