简体   繁体   中英

How index.js file is able to communicate with index.html?

In React project both index.html and index.js file are inside different folder and there is no link in between these two file. Then how we are able target div whose id is root of HTML file by using document.getElementById("root") inside index.js file.

please answer this in easy language because i have just start learning this, I am compeletly begineer.

React is one of the best JS libraries out there. It simplifies the development process without cluttering the implementation details explicitly. The index.html and index.js get linked during runtime when you start the script. React uses webpack under the hood where the entry for the webpack is index.js and when it is run(after all the conversions) it injects the javascript code in the HTML file which is index.html . And you can see this injected code in the index.html when you build the bundle inside the build folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM