Let’s start a fight (respectfully) 🥊
Recently, I came across a few React projects where the entire component was written in one file — logic, st...
For further actions, you may consider blocking this person and/or reporting abuse
Not a React dev. As I see it, a single file component in Vue or Svelte is closer to a web component.
Vue example
Here the separation between markup and logic is more visible.
In React it is a function with logic and markup.
That's not how web-component definition looks like. Read on MDN on how to create and define custom elements and you will see.
I mentioned it is closer, not that it is a web-component definition. I added the link to MDN, that would be stupid if i didn't read it first.
not even closer, makes no sense. A web-component is defined by doing.
class MyComp extends HTMLElementFrom MDM:
Doesn't that look a lot like a Vue or Svelte component?
That is not a web-component. Your link just shows an example of how the template tag can be used with web-components but this is not a web-component.
I've tried SFCs for quick MVPs and they do speed me up, but I always end up splitting things out as the project grows. Have you found a sweet spot where SFCs still work for big apps?
Totally relate. SFCs are great for fast iteration and MVPs, but yeah — as the app grows, keeping everything in one file can feel cramped. I’ve found that the sweet spot is using SFCs for atomic components or isolated logic/UI pieces, and gradually splitting concerns (like store, styles, or templates) only when complexity demands it.
So basically: start simple, scale structure as needed. You?
I'm a React dev and I love having one file per component and one CSS per component. It makes it much easier for CSS management.
Yea 100%, i am with you here. It makes life easier and more structured fr
This would be two files with the "Button.css" but I am ok with this for simple web sites.
SFCs feel like React’s version of a one-pot meal ..quick, satisfying, but maybe not for a five-course app 😄 Great convo starter..
Yea 100%, thanks tho💪🏼
SFCs are like pineapple on pizza ...weirdly good in the right context
If SFCs are like pineapple, custard, or strawberry-banana sandwiches on pizza, then yeah, you said everything about SFCs