DEV Community

Discussion on: 4 Reasons to Use React JS for Web Development

Collapse
 
perigk profile image
Periklis Gkolias

I believe Angular complicates frontend development for no reason. Separation of concerns is good, but I believe Angular overdoes it. For example, a known angular pattern is to have:

  • A .html for the UI
  • A .ts file for the dynamic logic, like event handling
  • A .css file
  • A service file to make requests
  • A helper BehaviorSubject based class for implementing the Observer pattern (I think)

On the other hand react looks more "to the point" to my eyes. Of course, this is just me. :)

  • One .jsx file that has the UI logic in the render function and the rest spread in various functions inside that file.
  • CSS lives in their own files, as it should and as usual.
  • Requests happen from inside the component, which makes the code simpler to read, though it can be offloaded to a utility file, if the operation is common.
  • Global state is stored in Redux or with React hooks (havent used them) or other similar tech
Collapse
 
baso53 profile image
Sebastijan Grabar

It really depends on what kind of project you are writing. If you are working on a project that has tons of logic, you would crave for the organization that Angular provides you. With React, people will often write code that doesn't follow some convention just because they can and nothing is stopping them. But you could also argue that they really aren't that different. Let's say you have a React project with only functional components. You end up with almost the same structure as Angular, you have these files - JSX file, file that handles the component logic (let's call it a service file), a .css file, and a resource file that handles requests. And I do believe that for really big projects, this is a very compelling solution. But the thing is, React doesn't force to do it this way, it's your job to do it. On the other hand, Angular provides you the frame for doing it this way, hence the name, framework.

Collapse
 
perigk profile image
Periklis Gkolias

Indeed, though I believe it is a matter of personal character too. Though the Angular way, is not the only way.

With a non-opionionated framework, you can do it whatever way you like. No framework can protect you from stupid and incompetent engineers :)