C
C#6mo 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
Angius6mo 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
KeyvanOP6mo ago
I used the create-react-project thing and not vite
Angius
Angius6mo ago
That's not recommended anymore But the principle is the same
Keyvan
KeyvanOP6mo ago
Its such a huge rabbit hole
Angius
Angius6mo ago
It is Javascript is a shitshow and a half
Keyvan
KeyvanOP6mo ago
the backend was not a rabbithole compared to this
Angius
Angius6mo ago
I don't even try to understand it anymore, I just use it
Keyvan
KeyvanOP6mo ago
hahahahhahah should i start over with vite? or can i just keep going I have done slim to none coding in frontend
Angius
Angius6mo 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
KeyvanOP6mo ago
Faster in what
Angius
Angius6mo 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
KeyvanOP6mo ago
but nothing impacting the webpage performace itself
Angius
Angius6mo ago
No, not at all
Keyvan
KeyvanOP6mo ago
Just for the Developer i guess?
Angius
Angius6mo ago
yep
Keyvan
KeyvanOP6mo ago
so essentially the App.tsx will be the main thing since <App/> is inside the root.render
Angius
Angius6mo ago
Yep
Keyvan
KeyvanOP6mo ago
I guess if i want multipage i need to make changes in APP then? routing?
Angius
Angius6mo ago
Bare react isn't really fit for multipage or SSR It's untimately an SPA framework
Keyvan
KeyvanOP6mo ago
How can i make it fit for multipage
Angius
Angius6mo ago
You can use it with a metaframework like Next.js, that will give you multipage and SSR support
Keyvan
KeyvanOP6mo ago
okok thanks!
Want results from more Discord servers?
Add your server