Popmotion / popmotion

Simple animation libraries for delightful user interfaces
https://popmotion.io
19.95k stars 662 forks source link

Popmotion: React import { animate } from "popmotion"; fails #923

Closed InfamousStarFox closed 2 years ago

InfamousStarFox commented 2 years ago

Using Popmotion version 10.0.2

The basic quick start:

import { animate } from "popmotion"

animate({
  from: 0,
  to: 100,
  onUpdate: latest => console.log(latest)
})

Causes my React site to fail to compile with the error:

./node_modules/popmotion/dist/es/animations/index.mjs
Can't import the named export '__rest' from non EcmaScript module (only default export is available)

What is the correct import for this to work?

mattgperry commented 2 years ago

It’s likely you’re using create-react-app which isn’t compatible with ES modules yet (see: https://github.com/framer/motion/issues/1307)

if you use the latest version of popmotion@9.x it should work as expected

InfamousStarFox commented 2 years ago

Yep, it looks like the problem is because create-react-app doesn't support the .mjs extension

Downgrading to 9.x fixed it.