Course map
Stage 1: Foundation
Stage 2: Intermediate
Stage 3: Advanced
Stage 4: Routing and Application Architecture
Stage 5: Specialization (pick ONE)

Part 16 / Topic 1 of 9

Feature folders vs. type folders

examples/01_feature_folders_vs_type_folders/ holds the same component and hook - OrderBadge and useOrderBadge - written twice, in two different folder shapes. The type-folders version groups by what each file is:

type-folders/
  components/OrderBadge.jsx
  hooks/useOrderBadge.js

The feature-folders version groups by what the files are for:

feature-folders/
  orders/OrderBadge.jsx
  orders/useOrderBadge.js

comparison.test.jsx renders both versions with describe.each and asserts identical output for the same count prop - 3 renders "3 orders" either way, 0 renders "No orders yet" either way. That's the actual argument this section is making, proven rather than claimed: reorganizing files changes nothing about behavior. The reason feature folders scale better isn't that they behave differently today - it's what happens when this app has forty features instead of one. In type folders, finding everything "the order badge" touches means already knowing to check components/ and hooks/ (and, in a real app, styles/ and tests/ too) - every new feature adds one more file to each of those folders, and deleting a feature means hunting across all of them to make sure nothing was left behind. In feature folders, the order feature's own folder is the answer to "what does this feature touch" - and deleting the feature is deleting one folder, not a grep-and-pray across four.

Done here? The practice set for Part 16 — including the solutions — is on the part page.

Search the guide