成帧器运动使下一个 js 应用程序崩溃,并出现以下错误:“SyntaxError:未找到命名导出‘useId’”

Rip*_*s55 4 javascript reactjs next.js framer-motion

我在下一个 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;
Run Code Online (Sandbox Code Playgroud)

当我从成帧器运动导入任何内容时,出现此错误,这是我的完整代码:

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;

Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

Sha*_*iar 5

useId是 React 18 中引入的新钩子。升级你的 React 版本并重试。