React是否会自动修剪已从DOM中删除其挂载点的组件? [英] Does React automatically prune components which have had their mount points removed from the DOM?

查看:71
本文介绍了React是否会自动修剪已从DOM中删除其挂载点的组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如果我使用renderComponent渲染到DOM节点,那么手动删除DOM节点,我只是泄漏了内存吗?是否已将已删除的DOM节点呈现的React组件进行了修剪?

For instance, if I use renderComponent to render to a DOM node, then delete the DOM node manually, did I just leak memory? Is the React component which was rendered to the deleted DOM node pruned?

推荐答案

您可能泄露了内存。使用 React.unmountComponentAtNode(节点)

You probably leaked memory. Use React.unmountComponentAtNode(node)

这篇关于React是否会自动修剪已从DOM中删除其挂载点的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆