ant-design / antd-style

css-in-js library with antd v5 token system
https://ant-design.github.io/antd-style/
MIT License
187 stars 29 forks source link

🧐[问题]Cannot read properties of null (reading 'useContext') #141

Closed Amazing-0921 closed 4 months ago

Amazing-0921 commented 4 months ago

TypeError: Cannot read properties of null (reading 'useContext') image

arvinxx commented 4 months ago

你的React相关依赖是不是配置得不对

Amazing-0921 commented 4 months ago

{ "private": true, "author": "", "scripts": { "dev": "umi dev", "build": "umi build", "postinstall": "umi setup", "setup": "umi setup", "start": "npm run dev" }, "dependencies": { "@ant-design/pro-components": "^2.6.49", "ace-builds": "^1.26.0", "antd": "^5.12.7", "antd-style": "^3.6.1", "axios": "^1.6.7", "immutability-helper": "^3.1.1", "react": "^18.2.0", "react-ace": "^10.1.0", "react-dom": "^18.2.0", "react-syntax-highlighter": "^15.5.0", "umi": "^4.0.76", "umi-request": "^1.4.0" }, "devDependencies": { "@types/lodash": "^4.14.198", "@types/react": "^18.2.46", "@types/react-dom": "^18.2.18", "@types/react-syntax-highlighter": "^15.5.7", "typescript": "^5.0.3" } }

大师,我该怎么改

arvinxx commented 4 months ago

@Amazing-0921

  1. 试一试清理依赖和缓存(删node_modules);
  2. 如果不行,试试关闭 mfsu
Amazing-0921 commented 4 months ago

删除 node_modules不行,关闭 mfsu 后可以,谢谢大师

arvinxx commented 4 months ago

那应该是 react 多实例的问题… 你找找umi文档里关于 mfsu 的部分看看,我记得有相关进一步配置介绍的

Amazing-0921 commented 4 months ago
mfsu: {
  shared: {
    react: {
      singleton: true,
    },
  },
},

换成 umi 文档里的配置阔以