yapi build提示出错: 28:5 error componentWillMount is deprecated since React 16.999.0, use UNSAFE_componentWillMount instead

ybzsozfc  于 2021-11-30  发布在  Java
关注(0)|答案(7)|浏览(602)

版本号

1.5.2

什么问题

在yapi目录下,执行 yapi build会提示:ykit: command not found
手工修改 /usr/local/lib/node_modules/yapi-cli/src/commands/build.js,添加:
shell.exec('npm install ykit --registry https://registry.npm.taobao.org');
再次执行 yapi build,会提示一堆error,例如:
[error] ./client/components/AuthenticatedComponent.js

/root/my-yapi/vendors/client/components/AuthenticatedComponent.js
28:5 error componentWillMount is deprecated since React 16.999.0, use UNSAFE_componentWillMount instead, see https://reactjs.org/docs/react-component.html#unsafe_componentwillmount. Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components react/no-deprecated
31:5 error componentWillReceiveProps is deprecated since React 16.999.0, use UNSAFE_componentWillReceiveProps instead, see https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops. Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components react/no-deprecated

✖ 2 problems (2 errors, 0 warnings)

[error] ./client/components/MyPopConfirm/MyPopConfirm.js

/root/my-yapi/vendors/client/components/MyPopConfirm/MyPopConfirm.js
29:3 error componentWillReceiveProps is deprecated since React 16.999.0, use UNSAFE_componentWillReceiveProps instead, see https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops. Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components react/no-deprecated

✖ 1 problem (1 error, 0 warnings)

如何复现此问题

1、全新Centos7系统,手工安装node11.0.0:
http://nodejs.org/dist/v11.0.0/node-v11.0.0.tar.gz
2、进入yapi安装目录,执行 yapi build 即可复现

什么浏览器

~

什么系统(Linux, Windows, macOS)

Centos7

kg7wmglp

kg7wmglp1#

源码中将componentWillReceiveProps替换成UNSAFE_componentWillReceiveProps即可,是因为react新版本中方法名改了

esyap4oy

esyap4oy2#

我也遇到了,是 eslint 新版本的问题。把eslint 相关配置关了就好了

xmd2e60i

xmd2e60i3#

安装yapi-plugin-gitlab插件的时候遇到了这个问题,请问有人安装yapi-plugin-gitlab成功了吗?

cyj0122/yapi-plugin-gitlab#16

fruv7luv

fruv7luv4#

将 "eslint-plugin-react" 版本 锁死在 7.1.0 可以解决这个问题

yws3nbqq

yws3nbqq5#

您这样操作后,解决了吗?

o2rvlv0m

o2rvlv0m6#

@yuqingc
你好,如何管理eslint的配置?

q43xntqr

q43xntqr7#

@wwb568109135 你先试一下楼上说的

如果不行,参考我的配置

  1. module.exports = {
  2. env: {
  3. "browser": true,
  4. "commonjs": true,
  5. "es6": true,
  6. "node": true
  7. },
  8. extends: ["eslint:recommended", "plugin:react/recommended"],
  9. parser: "babel-eslint",
  10. parserOptions: {
  11. "ecmaFeatures": {
  12. "jsx": true
  13. },
  14. "sourceType": "module"
  15. },
  16. plugins: [
  17. "react",
  18. "import"
  19. ],
  20. rules: {
  21. "indent": ["off", 2],
  22. "react/display-name": ["off"],
  23. "react/jsx-indent": ["error", 2],
  24. "comma-dangle": ["off"],
  25. "no-console": ["off"],
  26. "import/no-unresolved": ["off"],
  27. "react/no-find-dom-node": ["off"],
  28. "react/no-danger-with-children": ["off"]
  29. }
  30. };
展开查看全部

相关问题