如何理解加载的内容?

时间:2018-05-30 11:24:53

标签: reactjs iframe-resizer

我使用库iframe-resizer。所以,我创建了react - component。我等待在框架中加载内容时有任何时间我想在这个时间显示用户cirle-bar。如何理解装载是否完整?

1 个答案:

答案 0 :(得分:0)

您需要经历React.js的生命周期

有两种生命周期方法

  

componentWillMount() - 在加载DOM之前调用它。

     

componentDidMount() - 在加载DOM /完全呈现组件后调用。

所以你做了

componentWillMount(){
 //show MyLoader
}

componentDidMount(){
  // hide MyLoader
}

了解详情 - https://developmentarc.gitbooks.io/react-indepth/content/life_cycle/birth/premounting_with_componentwillmount.html

https://developmentarc.gitbooks.io/react-indepth/content/life_cycle/birth/post_mount_with_component_did_mount.html