DEV Community

Discussion on: Better file structure in React projects

Collapse
 
itays123 profile image
Itay Schechner

Personally, the vast majority of the hooks I write are written because I wanted to extract some logic from the UI component using it, and for that reason I place in in the same folder as the component.

For hooks used in multiple places, I usually create a helpers folder.

In a project where you have hooks that don't fall in neither of these two categories, foldering by role would be indeed the best choice. But I can't think of many examples that don't fall in one of these categories.