React - Display loading screen while DOM is rendering?

前端 未结 19 1667
我在风中等你
我在风中等你 2020-11-28 00:29

This is an example from Google Adsense application page. The loading screen displayed before the main page showed after.

I don\'t know how to do the same th

19条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 00:51

    I also used @Ori Drori's answer and managed to get it to work. As your React code grows, so will the bundles compiled that the client browser will have to download on first time access. This imposes a user experience issue if you don't handle it well.

    What I added to @Ori answer was to add and execute the onload function in the index.html on onload attribute of the body tag, so that the loader disappear after everything has been fully loaded in the browse, see the snippet below:

    
      
         
         
       
       
         more html here.....
       
    
    

提交回复
热议问题