DEV Community

Cover image for React-TypeScript Design Pattern 1 - Creational Design Patterns - Factory

React-TypeScript Design Pattern 1 - Creational Design Patterns - Factory

Fatemeh Paghar on March 10, 2023

In the "Design Pattern List" Post, you can find a categorized list of design patterns in software engineering. In some upcoming posts, I plan to co...
Collapse
 
imthedeveloper profile image
Info Comment hidden by post author - thread only accessible via permalink
ImTheDeveloper

Appreciate the sentiment here having to try and clean up an e-commerce front end theme that the Dev has utilised your exact example of adding and removing classes with js. It's horrible checking through various states to see what classes are being added removed at any point in time, couple this with different breakpoints and media queries being used it's a nightmare.

I learnt a few rough lessons in js around mutation of variables and the mess you can get into. I feel as though messing with classes can actually lead you down the same path. I like the data attribute idea, you can clearly see what is being targeted and it's before / after state options.

Collapse
 
fruntend profile image
Info Comment hidden by post author - thread only accessible via permalink
fruntend

Сongratulations 🥳! Your article hit the top posts for the week - dev.to/fruntend/top-10-posts-for-f...
Keep it up 👍

Some comments have been hidden by the post's author - find out more