ant-design / antd-style

css-in-js library with antd v5 token system

Home Page:https://ant-design.github.io/antd-style/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Amazing-0921 opened this issue · comments

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

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

{
"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"
}
}

大师,我该怎么改

@Amazing-0921

  1. 试一试清理依赖和缓存(删node_modules);
  2. 如果不行,试试关闭 mfsu

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

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

mfsu: {
  shared: {
    react: {
      singleton: true,
    },
  },
},

换成 umi 文档里的配置阔以