How you handle non reusable components in react?
Saurabh Sharma

Saurabh Sharma @itsjzt

About: Fullstack Web developer.

Location:
Delhi, India
Joined:
Nov 13, 2017

How you handle non reusable components in react?

Publish Date: Jan 16 '20
11 3

Do you create component for them?

Do you keep them in components folder
Or in separate folder?

Do you provide good types for them?

Comments 3 total

  • Joel Turner
    Joel TurnerJan 16, 2020

    Good question! I'm guessing it depends on your setup and if your building this as part of a team.

    On my dev team, we usually break them out into their own file unless it's a styled component just for that parent component.

    Currently we keep them in a folder for that specific item. For example, if we had a PanelRenderer that had a specific PanelChilr that only worked for it they would be placed in the PanelRenderer directory.

    Even if it's only used once, we prefer to type them fully. This helps with future refactors, bug fixes, additional features.

  • Ioannis Potouridis
    Ioannis PotouridisJan 17, 2020

    Hi!

    I won't provide an answer but a thought.

    I don't believe there's a reason making some block of code a component if it is not reusable.

    • Saurabh Sharma
      Saurabh SharmaJan 17, 2020

      Yeah, that a good option but parent components can be huge without extraction.

Add comment