I’ll be frank, there’s a lot of badly written React code out there. It’s really easy to slip into bad practices that make code unorganized and hard to read. In general, React is a very unopinionated framework compared to others like Angular, which can be incredibly powerful, but also makes it easier to introduce bad practices into your code. While writing a lot of React code, I’ve come up with a couple of ways to ensure that your code maintains readable and usable for not just yourself, but other devs.

1. File Organization

React doesn’t recommend a specific pattern to organize folder structure, but there are a couple of suggestions on their website. There’s quite a few  Medium articles floating around out there that recommend various file structures. I personally have adopted the  Atomic Design principle for all my projects. Regardless of which structure you pick, the important thing is consistency, maintainability, and readability. Ideally, a React developer should be able to look at the folder structure for a couple of minutes and have a general idea of where everything is.

#react #web-development

How to Write Better Code in React
16.80 GEEK