DEV Community

Discussion on: Introducing Responsive React Components 🔥

Collapse
 
flexdinesh profile image
Dinesh Pandiyan • Edited

In my opinion this goes against mobile first principles

Mobile first approach is the dream and I agree that this goes against mobile first principles but in my experience there's always something that cannot be truly responsive and needs to be handled with media queries.

And with your approach you're still having to write device specific styles

Yes, but these styles will be composed for specific components without having to be wrapped in css media queries.

if you handled the menu with specific device media-queries, you would still be loading the media queries not needed for desktop as an example

Not necessarily. If you use css modules or any css-in-js approach, your styles will be a part of your component and not separate stylesheet. But this is true if you extract your css into one big stylesheet. Instead you could separate your stylesheet for specific components and lazy load them.

I still stand with if media-queries can handle the change, then you should stick with media-queries without having to write device specific components.

I hear you. You don't need this if the application or requirement is small. But if your application is huge and if you often find yourself writing device specific media queries, this will make you happier.

20kb is quite a bit to just handle one device specific view, the menu must be really massive.

It was one big bundle of bloated foundation elements wrapped in React components with a very high level of customization.