A lot of front end developers nowadays find themselves contributing to component libraries. Component libraries usually consist of components that are

Don't overabstract your components

submited by
Style Pass
2021-05-27 21:30:31

A lot of front end developers nowadays find themselves contributing to component libraries. Component libraries usually consist of components that are reused throughout an application. Some are even used across many different applications. At some point you are tasked with adding a new component. One of the questions you should ask yourself early in the process is - "What should this component's API be?". That is first step in a process known as component API design.

What I mean by "component API" is how consumers of your component - mainly other developers - interact with it. So in the context of React - it's what props this component has.

Component API design takes some careful thought. The right API can reduce the code you have to write and maintain. At the same time, it can make your component more powerful 🤯.

When you are creating a new component - you are, generally, aiming to abstract something away. Whatever you are abstracting ends up being the component's functionality. What it does and the reason why it exists.

Leave a Comment