YMFE / yapi

YApi 是一个可本地部署的、打通前后端及QA的、可视化的接口管理平台
http://yapi.smart-xwork.cn/
Apache License 2.0
27.19k stars 4.77k forks source link

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

Open youbl opened 5 years ago

youbl commented 5 years ago

版本号

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

pinle88 commented 5 years ago

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

yuqingc commented 5 years ago

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

TianTian106 commented 5 years ago

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

https://github.com/cyj0122/yapi-plugin-gitlab/issues/16

leeonfield commented 5 years ago

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

wwb568109135 commented 3 years ago

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

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

wwb568109135 commented 3 years ago

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

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

yuqingc commented 3 years ago

@wwb568109135 你先试一下楼上说的

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

如果不行,参考我的配置

module.exports = {
    env: {
        "browser": true,
        "commonjs": true,
        "es6": true,
        "node": true
    },
    extends: ["eslint:recommended", "plugin:react/recommended"],
    parser: "babel-eslint",
    parserOptions: {
        "ecmaFeatures": {
            "jsx": true
        },
        "sourceType": "module"
    },
    plugins: [
        "react",
        "import"
    ],
    rules: {
        "indent": ["off", 2],
        "react/display-name": ["off"],
        "react/jsx-indent": ["error", 2],
        "comma-dangle": ["off"],
        "no-console": ["off"],
        "import/no-unresolved": ["off"],
        "react/no-find-dom-node": ["off"],
        "react/no-danger-with-children": ["off"]
    }
};