mercredi 3 février 2021

At what point should a component be abstracted in React?

This is a general React architecture question. In my web app I have 3 types of item. For these 3 items, each have a container that

  • gathers all the pertinent data(using redux hook useSelector)
  • renders the list of item of that type
  • render a filter for pertinent items
  • renders an item detail page for an item of that type

In the end, these 3 containers are extremely similar, fetch almost the same exact data, and just presents the data differently. For example a container for item 1 will fetch data on items 1, 2 and 3, but only render a list and detail for a type of item 1. My question is this: should I keep them as separate containers for the sake of separation of concerns and organization? Or should I abstract out a container component that takes the type of item as props and render accordingly?

Aucun commentaire:

Enregistrer un commentaire