在开始开发 Create React App 后添加 Chakra UI

Adding Chakra UI after starting development of Create React App

我尝试将 ChakraUI 添加到我的 create-react-app 后出现错误。希望得到任何帮助(也感谢有关将什么添加到 Whosebug 问题的建议)

I 运行 yarn add @chakra-ui/react @emotion/react@^11 @emotion/styled@^11 framer-motion@^4 按照 https://chakra-ui.com/docs/getting-started

中的建议

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

但是在 运行 yarn & yarn start 之后,我得到了关于 framer-motion 的这个错误: [TypeError: framer_motion__WEBPACK_IMPORTED_MODULE_1__.motion.custom 不是函数][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')
);

package.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

npm i framer-motion@3.10.6

对我有用,4.0 似乎有重大变化