- Non-redundant imports such as
import {Button} from Button
.
- Harder to identify which file is which.
- At the IDE, even with the tabs showing in smaller letter with folder the file is in, this only results in the tabs being unnecessarily larger.
- While doing fuzzy finding, you have to go looking for the path because almost all the files have the same name.
- Cleaner tabs as there are no reason to show the folder
- More intuitive fuzzy finding.
- It makes sense. If you are editing a button component,nothing more appropriate than the file being named
Button
.
- Redundant imports such as
import {Button} from Button/Button
.
- The component stays on the folder called
Component
, and the index of the folder calledindex
. This also makes exporting types and utils by the index more natural, since now it's responsibility is to be the index of the folder, and not to be a component. - More "modular" feeling of the folder, as you can import everything you need from that "module" (be it a component, a hook/provider or whatever) from the same file.
- All the pros of using
index.tsx
. - All the pros of using
Component.tsx
.
- The IDE will suggest two exports (
index.ts
andComponent.tsx
), which can be confusing.
Using a combination of both keeps the pros and has (IMO) the lesser of the cons, so it is an easy choice.