Next.js - Framer 运动:尝试导入错误:“useState”未从“react”导出(导入为“useState”)

问题描述 投票:0回答:1

我正在开发一个 next.js 项目,我想在其中使用 framer-motion。我刚刚开始这个项目,在安装和使用成帧器运动时遇到问题。我正在尝试创建一个简单的motion.div 组件并在另一个组件中使用它。

ERROR I get in the terminal while running "npm run dev" : 

./node_modules/framer-motion/dist/es/animation/hooks/use-animated-state.mjs
Attempted import error: 'useState' is not exported from 'react' (imported as 'useState').

我正在使用以下库/包:

我尝试降级framer-motion版本,但不起作用。如果有人能帮忙那就太好了。

谢谢。

reactjs node.js next.js node-modules framer-motion
1个回答
0
投票

我通过将“使用客户端”添加到我需要framer-motion api的组件中解决了这个问题

© www.soinside.com 2019 - 2024. All rights reserved.