Menu

37 components in our Expo app, and the one nothing has ever imported was written in the first commit
📰

37 components in our Expo app, and the one nothing has ever imported was written in the first commit

DEV Community: typescript·Daniel Pertu·1 day ago
#juBxTFtJ
#devtotypescript#devto#dev#screen#components
Reading 0:00
15s threshold

Munchable 's app has no component library under it. 37 hand-written components, 3,056 lines, 83 lines each on average, and everything on screen is built out of them. I wanted to know which ones were actually load-bearing, so I counted importers: for each component, how many other files in src/ and app/ mention it at all, excluding its own file.

The top of the list is unsurprising and the bottom is the interesting part.

Text 37 Icon 29 Screen 17 Button 13 Header 10 Collapsible 8 DisclosureChevron 7 ... ConfidenceBadge 1 Glow 1 SelectionCanvas 1 StillCrop 1 SummaryRow 1 VerdictHero 1 ... Stack.web 0 VerdictChip 0

Enter fullscreen mode

Exit fullscreen mode

Eleven components have exactly one importer. Two have none.

One of the zeroes is the bundler doing its job

Stack.web.tsx has no importers and never will. Metro resolves platform extensions: a file importing ./Stack gets Stack.web.tsx on web and Stack.tsx everywhere else, so the web variant is reached by a name nobody types.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.