I
I
Ivan-P2019-03-22 23:35:36
Angular
Ivan-P, 2019-03-22 23:35:36

Why do we need small React / Angular components?

I have 4 years of experience in web development, 3 years of writing in Angular. I have always worked in companies where all the fronts were pure anglers. And then, by the will of fate, I find myself in a new company, where half of the front-end workers wrote in most cases in react. Since the project is new, being written from scratch, a little chaos reigns, the architecture, style code, etc. are still being discussed and approved. And at the next rally, I hear about the need to write such components as .. button, input, checkbox ...
No, well, I understand that and I always do the removal of pieces of code into separate components, which are reused many times, somehow item-product, menu, sidebar, table... But BUTTON! But INPUT!!!
It would seem that I considered myself someone in between a middle and a senior, I bothered with higher matters, complex structures and abstractions, although I didn’t shun if something needed to be done, but it doesn’t fit in my head why to recognize a component, write tests for it , inside which there will be only one html tag, on which attributes will be hung with parameters, css classes will be added if it is possible to hang the necessary html tags and css classes anyway!? Why do such a boilerplate job? Why create extra code that will once again load the browser with empty JS work if everything is already thought up in html? From colleagues, I could only get a rather specific explanation that I was a retrograde and "so cool" ...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Filippov, 2019-03-23
@Ivan-P

I don’t understand what the question is, the button can / should be moved to a separate component in order to reuse it in several places without code duplication. Everything.

A
Anton Shvets, 2019-03-23
@Xuxicheta

Angular discourages making many small components. In Angular, a component is a big thing.
In the same view, it is simpler, you joyfully sculpt a bunch of components on any sneeze.
After all, there are directives for the things you write about.
And if instead of wanting instead of trying to do<input [class.loading]="loading" type="button">

<app-my-button [loading]="loading"></app-my-button>
and to stick a whole component for this, then this is already generally a reaction of the brain.
People just don't know how to use Angular, that's the whole answer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question