美文网首页
react中项目componentWillMount警告

react中项目componentWillMount警告

作者: 我是哈斯 | 来源:发表于2020-12-07 16:10 被阅读0次

    第一步CD进入你的项目:

        cd your_project
    

    第二步输入:

        npx react-codemod rename-unsafe-lifecycles
    

    第三步将你的代码进行修改

    componentWillMount → UNSAFE_componentWillMount
    componentWillReceiveProps → UNSAFE_componentWillReceiveProps
    componentWillUpdate → UNSAFE_componentWillUpdate
    

    第四步将你模块的手动修改

    找到模块 react-loadable

    LoadableComponent.prototype.UNSAFE_componentWillMount = function UNSAFE_componentWillMount() {
          this._mounted = true;
          this._loadModule();
        };
    

    第五步重新启动的你项目

        npm start

    相关文章

      网友评论

          本文标题:react中项目componentWillMount警告

          本文链接:https://www.haomeiwen.com/subject/ncrtgktx.html