0

尝试将 ChakraUI 添加到我的 create-react-app 后,出现错误。希望得到任何帮助(也感谢向stackoverflow问题添加内容的建议)

我按照https://chakra-ui.com/docs/getting-startedyarn add @chakra-ui/react @emotion/react@^11 @emotion/styled@^11 framer-motion@^4中的建议运行

我使用 CRA 来启动我的应用程序,但在我已经开始一些开发之后决定添加脉轮。这就是为什么我没有使用yarn create react-app my-app --template @chakra-ui

但是,在运行后yarnyarn start收到有关 framer-motion 的错误:[TypeError: framer_motion__WEBPACK_IMPORTED_MODULE_1__.motion.custom is not a function][1]

我的 index.js 文件如下所示:

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import { ChakraProvider } from '@chakra-ui/react';

ReactDOM.render(
  <React.StrictMode>
    <ChakraProvider>
      <App />
    </ChakraProvider>
  </React.StrictMode>,
  document.getElementById('root')
);

包.json:

{
  "name": "gad-questionaire",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@chakra-ui/react": "^1.3.4",
    "@emotion/react": "^11",
    "@emotion/styled": "^11",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "framer-motion": "^4",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

使用反应版本:17.0.1

提前感谢您的任何建议 [1]:https ://i.stack.imgur.com/Vs3oU.png

4

1 回答 1

4

npm i framer-motion@3.10.6

为我工作,4.0 似乎有重大变化

于 2021-03-21T00:44:45.840 回答