C
C#2mo ago
Keyvan

Creating react TS frontend for my C# .net backend

I have started to look into my frontend after completing the backbone of the backend. I really dont understand how react apps run. I have background in C so i am used to having a main function that starts everything. With the created react TS environment now i dont understand where i should put things. I have made atomic design (atoms, mollecules etc.), but where does stuff actually get executed. I have researched alot online the past days an i cannot find anything helpful.
22 Replies
Angius
Angius2mo ago
index.html is what loads the bundle that gets created when a React project gets compiled Let me tell you ahead of time, though: with anything JS worrying about things like where what gets executed, atomicity, et cetera, is a futile effort Everything is made so that you write your code, build it with some arcane process that gets reduced to vite build, and it works You'd have to inspect the final bundle to figure out how the code is routed But it sill be minified into gibberish, so it's not much of an option You just make components and use them, that's the gist of it. The build process handles the rest
Keyvan
Keyvan2mo ago
I used the create-react-project thing and not vite
Angius
Angius2mo ago
That's not recommended anymore But the principle is the same
Keyvan
Keyvan2mo ago
Its such a huge rabbit hole
Angius
Angius2mo ago
It is Javascript is a shitshow and a half
Keyvan
Keyvan2mo ago
the backend was not a rabbithole compared to this
Angius
Angius2mo ago
I don't even try to understand it anymore, I just use it
Keyvan
Keyvan2mo ago
hahahahhahah should i start over with vite? or can i just keep going I have done slim to none coding in frontend
Angius
Angius2mo ago
You can keep going, it's not that much of a differece Vite is simply faster than React, and it's universal You can use Vite with React, Vue, Svelte, Solid, Qwik, Astro, whatever One tiny little bit of standardization in the hellhole that is frontend
Keyvan
Keyvan2mo ago
Faster in what
Angius
Angius2mo ago
Unless something that replaces Vite comes out Faster builds, faster dev thanks to hot module replacement Easier config Just better DX in general
Keyvan
Keyvan2mo ago
but nothing impacting the webpage performace itself
Angius
Angius2mo ago
No, not at all
Keyvan
Keyvan2mo ago
Just for the Developer i guess?
Angius
Angius2mo ago
yep
Keyvan
Keyvan2mo ago
so essentially the App.tsx will be the main thing since <App/> is inside the root.render
Angius
Angius2mo ago
Yep
Keyvan
Keyvan2mo ago
I guess if i want multipage i need to make changes in APP then? routing?
Angius
Angius2mo ago
Bare react isn't really fit for multipage or SSR It's untimately an SPA framework
Keyvan
Keyvan2mo ago
How can i make it fit for multipage
Angius
Angius2mo ago
You can use it with a metaframework like Next.js, that will give you multipage and SSR support
Keyvan
Keyvan2mo ago
okok thanks!