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