首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >framer在下一个js应用程序中崩溃,有以下错误:"SyntaxError:命名导出'useId‘not“

framer在下一个js应用程序中崩溃,有以下错误:"SyntaxError:命名导出'useId‘not“
EN

Stack Overflow用户
提问于 2022-10-20 21:59:21
回答 1查看 229关注 0票数 0

我在我的下一个js应用程序中得到了这个错误,我甚至不知道它是从哪里来的,因为抛出错误的代码甚至不是我写的。

代码语言:javascript
复制
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;

当我从framer运动中导入任何内容时,我会得到这个错误,下面是我的完整代码:

代码语言:javascript
复制
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;

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-20 22:13:05

useId是Resive18中引入的一个新钩子。请升级您的React版本,然后再试一次。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74146727

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档