reactjs - 当我们在 react 中点击 componentDidMount 时,组件安装在哪里?它是真正的 DOM 还是 VirtualDom?
问题描述
你什么时候会在 react 中点击 componentDidMount 钩子?是在组件安装到虚拟 dom 还是实际 dom 时?
解决方案
render()
该组件在“渲染阶段”安装到虚拟 DOM 。
生命componentDidMount
周期是“提交阶段”的一部分,被挂载到实际的 DOM。
请注意,如果您调用setState
.componentDidMount
您可以
setState()
立即致电componentDidMount()
。它会触发额外的渲染,但会在浏览器更新屏幕之前发生。
推荐阅读
- python - 使用 Beautifulsoup 在 Python 中抓取网页链接
- python - 为什么 CSS 选择器在等待元素可点击后无法点击元素?
- python - 如何在python中将JD转换为日期?
- amazon-s3 - 如何修复s3上的cors
- python - 在 seaborn 线图中绘制多条线
- dart - 扑腾的音频播放器
- nao-robot - NAO机器人的奇怪姿势
- c - 为什么我的 CRITICAL_SECTION 的 RecursionCount 这么大?调试死锁
- python - sklearn inverse_transform 返回巨大的值并将 MAE 降至零
- android - 一个 EditText 的 OnKey 事件适用于两个 EditText,如何解决此问题?