Summary of front-end projects - why componentization?

The first contact with the idea of ​​componentization is by writing react. As more and more projects are done, the idea of ​​componentization becomes more and more important.

Regarding the layering of the current project, I have introduced it in the previous blog.

In normal business scenarios, we would do this layering of projects.

  • basic components
    • The so-called basic component, we can also understand it as a widget, that is, a component. Such as Input, Button, AutoComplete and so on. They can be used anywhere.
  • business component
    • The business components I understand are components. These components are composed of basic components. According to the needs of different business scenarios, business components with data and logic are formed. Of course, these business components can also be abstracted into a component that can be used by multiple module components, such as the footer of the fix at the bottom of the page, which may integrate the home page module, user information module, jump information of the product list module, etc., so each Modules all need to have it.
  • Module components
    • This is one of the modules we have specified according to specific business needs, such as login, product details page and so on. It is the integration of business components with foundational components.

So back to the original question, why do we do componentization? Through the above split, it is not difficult to see that componentization can make our code less coupled, and we don't have to rub everything like traditional development. Together, we have greatly improved our development efficiency. At the same time, we avoid reinventing the wheel, improving our code quality and reducing maintenance costs.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325914136&siteId=291194637