What’s the relationship between index.html and JavaScript files in src in React?

I’m confused with the React files, I can’t understand how the index.html in public folder connects to JS files in src folder without using any script tags?

I deleted all the files in src file and created a new JS file called it a.js then when I ran npm start, it gave the error below:

Code:

//a.js
import React from 'react';
import ReactDOM from 'react-dom/client';

const root1 = ReactDOM.createRoot(document.getElementById('root'));
root1.render(

<h2>hey</h2>
);

Error:

Could not find a required file.

  Name: index.js

  Searched in: D:counter-appsrc

What’s going on here?