CJY0208 / react-activation

Hack <KeepAlive /> for React
https://www.npmjs.com/package/react-activation
MIT License
1.81k stars 141 forks source link

drop当前组件引起React Warning #170

Closed JqhSdtz closed 2 years ago

JqhSdtz commented 2 years ago

直接用umi-keep-alive-tabs-demo中的代码

function dropTab(e) {
    e.stopPropagation()
    const currentName = node.name

    if (location.pathname === node.name) {
      dropScope(currentName)
      // 前往排除当前 node 后的最后一个 tab
      history.push(
        cachingNodes.filter((node) => node.name !== currentName).pop().name
      )
    } else {
      dropScope(currentName)
    }
  }

在history.push之后大概1s控制台会输出错误 猜测可能是Keeper组件在unmount之后没有clearTimeout导致React提示可能造成内存泄露 react版本17.0.2,react-activation版本0.9.9 在此表示感谢! 报错截图: 截图_20220227221222 出错部分的代码: 截图_20220227221542

CJY0208 commented 2 years ago

OK,v0.9.11 中修复了~