5 Comments
User's avatar
Radoslav Stankov's avatar

Good points.

I had a similar post a long time ago.

https://blog.rstankov.com/structuring-react-components/

I prefer the exported types and main components to be on the top and all internal file types, helpers, and subcomponents to be below it.

Because one usually reads files from top to bottom, the file is organized in terms of priority. We, more often than not, use a component rather than modify it. Thus, the external components and interfaces are more important than the internal details.

Expand full comment
Petar Ivanov's avatar

Thank you for adding this, Rado! I like both approaches + extracting these things outside the main component into separate files.

Expand full comment
Daniel Moka's avatar

Solid tips my friend ,they are part of Clean Code.

Expand full comment
Petar Ivanov's avatar

Thank you, Daniel! 🙌

Expand full comment
Mikita Aliaksandrovich's avatar

Interesting points! Thanks for sharing!

Expand full comment