Code:

Note: I used yoyo and loop in the video. In fact, they will be deprecated soon. A new, and better way is via repeat and repeatType, like so:

<motion.div animate={{ scale: 4 }} 
  transition={{ repeat: Infinity, repeatType: 'reverse'}}>

See the official doc for more details.