x icon indicating copy to clipboard operation
x copied to clipboard

expected Application Error! undefined is not an object (evaluating 'Context._context')

Open bianbiandashen opened this issue 1 year ago • 5 comments

重现步骤

ontext@http://127.0.0.1:8080/static/js/lib-react.js:40353:16 useInternalToken@http://127.0.0.1:8080/static/js/vendors-node_modules_pnpm_ant-design_colors_7_1_0_node_modules_ant-design_colors_es_index_js--2d51ba.js:7560:62 useToken@http://127.0.0.1:8080/static/js/vendors-node_modules_pnpm_ant-design_colors_7_1_0_node_modules_ant-design_colors_es_index_js--2d51ba.js:7452:114 @http://127.0.0.1:8080/static/js/vendors-node_modules_pnpm_ant-design_colors_7_1_0_node_modules_ant-design_colors_es_index_js--2d51ba.js:918:32 @http://127.0.0.1:8080/static/js/vendors-node_modules_pnpm_ant-design_colors_7_1_0_node_modules_ant-design_colors_es_index_js--2d51ba.js:849:31 Bubble@http://127.0.0.1:8080/static/js/vendors-node_modules_pnpm_ant-design_colors_7_1_0_node_modules_ant-design_colors_es_index_js--2d51ba.js:6699:93 renderWithHooks@http://127.0.0.1:8080/static/js/lib-react.js:15492:27 updateForwardRef@http://127.0.0.1:8080/static/js/lib-react.js:19246:35 beginWork$1@http://127.0.0.1:8080/static/js/lib-react.js:27466:23 performUnitOfWork@http://127.0.0.1:8080/static/js/lib-react.js:26597:23 workLoopSync@http://127.0.0.1:8080/static/js/lib-react.js:26506:22 renderRootSync@http://127.0.0.1:8080/static/js/lib-react.js:26474:19 recoverFromConcurrentError@http://127.0.0.1:8080/static/js/lib-react.js:25890:34 performConcurrentWorkOnRoot@http://127.0.0.1:8080/static/js/lib-react.js:25790:48 workLoop@http://127.0.0.1:8080/static/js/lib-react.js:41796:42 flushWork@http://127.0.0.1:8080/static/js/lib-react.js:41769:22 performWorkUntilDeadline@http://127.0.0.1:8080/static/js/lib-react.js:42063:42 @http://127.0.0.1:8080/static/js/lib-polyfill.js:8519:12 run@http://127.0.0.1:8080/static/js/lib-polyfill.js:8493:7 eventListener@http://127.0.0.1:8080/static/js/lib-polyfill.js:8504:6

packjson: { "name": "@xhs/modular-webui", "version": "3.3.19", "main": "./dist/html/main/index.html", "scripts": { "reset": "npx rimraf ./**/node_modules", "dev": "modern dev", "build": "modern build", "start": "modern start", "serve": "modern serve", "new": "modern new", "lint": "modern lint", "upgrade": "modern upgrade" }, "dependencies": { "@ant-design/icons": "^5.2.6", "@ant-design/pro-components": "^2.7.10", "@ant-design/x": "^1.0.0", "@fortawesome/fontawesome-svg-core": "^6.6.0", "@fortawesome/react-fontawesome": "^0.2.2", "@modern-js/plugin-tailwindcss": "2.46.1", "@modern-js/runtime": "2.46.1", "@monaco-editor/react": "^4.6.0", "@tauri-apps/api": "^1", "@tauri-apps/cli": "^1.5.14", "@uiw/react-codemirror": "^4.22.2", "@xhs/apm-insight": "^1.1.20", "@xhs/di": "0.1.3-beta.1", "@xhs/launcher": "^3.24.0", "@xhs/modular-chat": "workspace:^", "@xhs/modular-layout": "workspace:^", "@xhs/modular-rpc": "*", "@xhs/module-utils": "0.1.0-beta.1", "@xhs/react-di": "^0.1.1", "antd": "^5.13.2", "axios": "^1.7.2", "codemirror": "^5.65.0", "dayjs": "^1.11.9", "events": "^3.3.0", "hotkeys-js": "^3.13.7", "js-cookie": "^3.0.5", "lodash-es": "^4.17.21", "mobx": "^6.13.2", "monaco-editor": "^0.45.0", "prop-types": "^15.8.1", "react-codemirror2": "^7.2.1", "react-monaco-editor": "^0.56.1", "react-spring": "^9.7.4", "react-transition-group": "^4.4.5", "styled-components": "^6.1.13", "xterm": "^5.3.0", "xterm-addon-fit": "^0.8.0", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", "@types/jest": "^27.5.2", "@types/node": "^16.18.119", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "react": "^18.3.1", "react-dom": "^18.3.1", "react-scripts": "5.0.1", "typescript": "^4.9.5", "web-vitals": "^2.1.4"

}, "devDependencies": { "@babel/core": "^7.24.7", "@babel/preset-env": "^7.24.7", "@babel/preset-react": "^7.25.9", "@modern-js-app/eslint-config": "2.46.1", "@modern-js/app-tools": "2.46.1", "@modern-js/eslint-config": "2.46.1", "@modern-js/tsconfig": "2.46.1", "@types/jest": "~29.2.4", "@types/lodash-es": "^4.17.12", "@types/node": "~16.11.7", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "react": "^18.3.1", "react-dom": "^18.3.1", "react-scripts": "5.0.1", "@xhs/react-di": "^0.1.1", "babel-loader": "^6.4.1", "husky": "~8.0.1", "lint-staged": "~13.1.0", "mobx-react-lite": "^4.0.7", "monaco-editor-webpack-plugin": "^7.1.0", "prettier": "~2.8.1", "rimraf": "~3.0.2", "tailwindcss": "~3.3.3", "typescript": "~5.0.4" }, "publishConfig": { "access": "public", "registry": "http://npm.devops.xiaohongshu.com:7001/" } }

当前行为

No response

预期行为

No response

上下文

No response

版本

1.0.0

您在哪些浏览器上遇到了这个问题?

No response

bianbiandashen avatar Nov 23 '24 08:11 bianbiandashen

使用方式 import React from 'react'; import { Bubble } from '@ant-design/x';

const App: React.FC = () => (

);

export default App;

bianbiandashen avatar Nov 23 '24 08:11 bianbiandashen

import React from 'react'; import { Bubble } from '@ant-design/x';

const App: React.FC = () => (

);

export default App;

bianbiandashen avatar Nov 23 '24 08:11 bianbiandashen

bianbiandashen avatar Nov 23 '24 08:11 bianbiandashen

我尝试着本地进行复现,没有发现对应的报错,具体步骤:

step1

按照上文中提供的 package.json 新建工程

由于你提供的 package.json 有类似 "@xhs/modular-chat": "workspace:^" 这样的 workspace 依赖,所以我只安装了必要的包

npx create-react-app modular-webui --template typescript
cd modular-webui

npm install @ant-design/pro-components@^2.7.10 @ant-design/x@^1.0.0
npm install antd@^5.13.2 react@^18.3.1 react-dom@^18.3.1

npm start

step2

src/App.tsx

import { Button } from 'antd';
import { ProCard } from '@ant-design/pro-components';
import { Bubble } from '@ant-design/x';

const App = () => (
  <div>
    <Button>Ant Design Button</Button>
    <Bubble content="Ant Design X Bubble" />
    <ProCard title="Ant Design Pro Card" />
  </div>
);

export default App;

结果

image

建议

  1. 看起来可能与 React 的 Context 有关,可以检查下本地的相关依赖版本。
npm ls antd @ant-design/pro-components @ant-design/x react
  1. 提供更详细的可复现途径

YumoImer avatar Nov 23 '24 14:11 YumoImer

你本地的antd版本是不是跟antd-x所依赖的版本不一致,尝试将项目的antd版本升级高于antd-x所依赖的antd版本即可

WutBottle avatar Nov 26 '24 01:11 WutBottle

貌似已经解决了,如果没有其他问题,我先关闭该 issue 了。

YumoImer avatar Nov 27 '24 06:11 YumoImer