帧移动使下一个 JS 应用程序崩溃,并显示以下错误:"SyntaxError: Named export 'useId' not found"



我在下一个js应用程序上收到了这个错误,我甚至不知道为什么或从哪里来,因为引发错误的代码甚至不是我写的。

error - file:///Users/cheq/Desktop/cheqo/node_modules/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs:1
import { useContext, useId, useEffect } from 'react';
^^^^^
SyntaxError: Named export 'useId' not found. The requested module 'react' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'react';
const { useContext, useId, useEffect } = pkg;

当我从成帧器运动导入任何东西时,我会遇到这个错误,这是我的完整代码:

import React from 'react';
import { motion } from 'framer-motion';
function motionpage() {
return (
<>
<div>motionpage</div>
<motion.button whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }}>
Button
</motion.button>
</>
);
}
export default motionpage;

我该怎么解决这个问题?

useId是React 18中引入的一个新钩子。升级react版本,然后重试。

相关内容

最新更新