15 KiB
React Doctor — apps/user-ui/app/(drawer)/(tabs)/home/
Date: 2026-11-02
Tool: react-doctor@0.9.22 (millionco)
Command:
cd apps/user-ui
npx --yes react-doctor@latest --no-telemetry --blocking none --verbose \
'app/(drawer)/(tabs)/home'
Scope: 11 files, 1,217 lines — index.tsx, search-results/index.tsx,
order-success.tsx, _layout.tsx, cart.tsx, checkout.tsx, plus the
product-detail/ and slot-view/ route files.
Scan result: ✔ Scanned 11 files in 1.3s — 11 issues (2 errors,
9 warnings). Score output disabled (--no-telemetry).
No code was changed for this report. Each finding below was verified against the source; verdicts are mine, not the tool's.
Summary
| # | Rule | Location | Sev | Category | Verdict |
|---|---|---|---|---|---|
| 1 | rn-no-scrollview-mapped-list |
index.tsx:227 |
warn | Bugs | False positive (by design) |
| 2 | duplicate-jsx-subtree |
index.tsx:444 |
warn | Maintainability | True positive (low) |
| 3 | no-giant-component |
index.tsx:491 |
warn | Maintainability | True positive (medium) |
| 4a | exhaustive-deps |
index.tsx:587 |
warn | Bugs | True positive (medium) |
| 4b | exhaustive-deps |
search-results/index.tsx:75 |
warn | Bugs | False positive in practice |
| 5 | no-impure-state-updater |
index.tsx:590 |
error | Bugs | True positive (medium) |
| 6 | no-side-effect-in-state-updater-function |
index.tsx:592 |
warn | Bugs | Same root cause as #5 |
| 7 | rerender-memo-before-early-return |
index.tsx:756 |
warn | Performance | True positive (negligible) |
| 8 | rn-no-falsy-and-render |
order-success.tsx:47 |
error | Bugs | False positive |
| 9 | rn-list-callback-per-row |
search-results/index.tsx:98 |
warn | Bugs | True positive (low) |
| 10 | expo-lockfile |
package.json |
warn | Correctness | True positive (repo-level, out of scope) |
Status after the fixes
Fixed in the working tree (see change-log.txt):
| Finding | Fix |
|---|---|
| #5 / #6 impure updater | hasMore is derived (visibleCount < displayedProducts.length); showMore is a pure updater |
| #4a missing effect deps | the sort effect now lists getQuickestSlot and isSlotsLoaded |
| #9 inline row handler | memoized SearchResultItem owns its onPress; the screen passes a stable handler |
| #2 duplicated heading | shared SectionHeading used by both sections |
| #3 giant component | catalogue derivation moved to hooks/useHomeCatalog.ts; Dashboard 346 → ~270 lines |
| #7 memo before early return | ShowMoreFooter is a component rendered after the early returns |
#4b unstable allProducts |
memoised on productsData (tidy, same behaviour) |
Re-scan of the same folder: 11 issues → 3 issues. The three that remain are #1, #8 and #10 above — the two false positives and the lockfile decision.
React Doctor — home
3 issues
⚠ react-doctor/rn-no-scrollview-mapped-list index.tsx:227
✖ react-doctor/rn-no-falsy-and-render order-success.tsx:47
⚠ react-doctor/expo-lockfile package.json
1. rn-no-scrollview-mapped-list — index.tsx:227
Tool says: <ScrollView>{items.map(...)}</ScrollView> builds every row at
once; use FlatList/FlashList.
Code:
// TagTabStrip
<ScrollView horizontal testID="home-tag-strip" ...>
{routes.map((route, i) => { ... })}
</ScrollView>
Verdict: false positive. This is deliberately a horizontal tab strip, not a data list. It has a comment saying so:
// Fixed, horizontally scrollable tab strip (plain ScrollView — no nesting,
// so it scrolls reliably on Android). Sits OUTSIDE the vertical FlatList.
The row count is the number of dashboard tags in a region (small, bounded), and
the strip relies on onLayout to record each tab's x-position for the
auto-scroll-to-active effect. A FlatList would make that position tracking
harder and add virtualization churn for ~5–10 items.
Confidence: high. Action: leave as is. If you want a clean report, add a line-scoped disable with the reason rather than changing the component.
2. duplicate-jsx-subtree — index.tsx:444
Tool says: 2 copies of a 6-node JSX tree, ~9 lines each, in one file.
Code: the section heading in SlotsSection (line ~441) and AllProductsTitle
(line ~470) are near-identical:
<View style={tw`flex-row items-center mb-1.5`}>
<View style={tw`w-1 h-5 rounded-full bg-brand500 mr-2.5`} />
<MyText style={tw`text-2xl font-extrabold text-gray-900 tracking-tight`}>…</MyText>
</View>
<MyText style={tw`text-sm text-gray-500 font-medium ml-4`}>…</MyText>
Verdict: true positive. Low risk, pure presentation.
Confidence: high.
Suggested fix: extract SectionHeading({ title, subtitle, subtitleIndent })
and use it in both places. The two copies differ only in mt-2 / mb-[11px] vs
mt-2 / mb-4 and the copy text — pass those as props. Behaviour unchanged.
3. no-giant-component — index.tsx:491
Tool says: Dashboard is over 300 lines.
Verdict: true positive. Dashboard spans lines 491–837 (~346 lines).
It is already better than it used to be — RenderStore, SlotCard, TagTabStrip,
TagScene, ExploreProductItem, SlotsSection, AllProductsTitle,
EmptyCatalog and the virtualized item renderers are separate components. The
remaining body is mostly:
- 6
useState+ 4 central-store selectors +useProductSlotIdentifierand the four data hooks, - the catalogue memo,
- the sort/effect that produces
displayedProducts, - search bar, sections memo, list header/footer memos,
- two early returns,
- the
SectionListwiring.
Confidence: high. Suggested fix (incremental, not one pass):
- Move "catalog → sorted rows" into a custom hook (
useHomeCatalog) — removes the effect, the sort and three pieces of state from the component. - Move search bar + header/footer into a
<HomeListChrome>component. - Then
Dashboardis mostly hooks + one<SectionList>.
Items 1 and 2 also fix findings #4a, #5 and #7.
4a. exhaustive-deps — index.tsx:587
Tool says: the effect can run with stale getQuickestSlot and
isSlotsLoaded.
Code:
React.useEffect(() => {
...
.sort((a, b) => {
const slotA = getQuickestSlot(a.id)
const slotB = getQuickestSlot(b.id)
const aOutOfStock = Boolean(productSlotsMap[a.id]?.isOutOfStock) || (isSlotsLoaded && !slotA)
...
})
setDisplayedProducts(allSorted)
setVisibleCount(21)
setHasMore(allSorted.length > 21)
}, [products, productSlotsMap])
Verdict: true positive. getQuickestSlot and isSlotsLoaded are read but
not listed. Concretely: when slots finish loading, productSlotsMap usually
changes and re-runs this, but isSlotsLoaded flipping is what makes
"no slot ⇒ out of stock" correct, and it is not a dependency. Ordering can stay
stale for a render (or longer if the map identity happens to be reused).
Why it's safe to add them (no loop): getQuickestSlot is already
useCallback-memoized on [slots, productSlotsMap]
(apps/user-ui/hooks/useProductSlotIdentifier.ts), and the effect writes only
displayedProducts / visibleCount / hasMore, none of which it depends on. So
adding the deps cannot self-trigger.
Confidence: high.
Suggested fix: }, [products, productSlotsMap, getQuickestSlot, isSlotsLoaded]).
4b. exhaustive-deps — search-results/index.tsx:75
Tool says: allProducts is rebuilt every render, so the useMemo runs every
time.
Code:
const allProducts = productsData?.products || []
...
const products = useMemo(() => { ...fuse... }, [allProducts, debouncedQuery])
Verdict: false positive in practice. When data is loaded,
productsData.products is a stable reference (useAllProducts memoizes
mergedData), so || returns the same array and the memo holds. The []
fallback is only created while productsData is undefined — at which point the
list is empty anyway. The extra memo pass costs nothing measurable.
Confidence: high.
Optional tidy: const allProducts = useMemo(() => productsData?.products ?? [], [productsData]).
Do it only if you want the warning gone; no user-visible change either way.
5 & 6. State updater with side effects — index.tsx:590 / :592
Tool says (error): "This state updater performs the nested state update
setHasMore()." And a second warning for the side effect itself.
Code:
const handleShowMore = useCallback(() => {
setVisibleCount((prev) => {
const next = prev + 21;
setHasMore(next < displayedProducts.length); // side effect inside updater
return next;
});
}, [displayedProducts.length]);
Verdict: true positive, and it is real. React may invoke a state updater more
than once (StrictMode double-invoke, replay of an interrupted render), so
setHasMore can be scheduled twice. In practice this is benign because the value
is computed from state, but the updater is not pure, which is exactly what the
rule exists to catch.
Root cause: hasMore is derived state. It is only used at index.tsx:757
(listFooter) and is fully determined by two values already in scope:
const hasMore = visibleCount < displayedProducts.length
Confidence: high. Suggested fix (removes both findings):
- Delete the
hasMorestate (:498) and bothsetHasMorecalls (:592,:586). - Compute
const hasMore = visibleCount < displayedProducts.lengthafter the state declarations. handleShowMorebecomessetVisibleCount((prev) => prev + 21), deps[].
Behaviour note: at first mount displayedProducts is empty, so the derived value
is false where the initial state was true. The footer is not rendered before
the catalog loads, and the effect sets the real value immediately, so nothing
visible changes. This is strictly more correct (no window where Show More can
show with nothing more to show).
7. rerender-memo-before-early-return — index.tsx:756
Tool says: the useMemo JSX is rebuilt on renders that take the early return.
Code: listFooter is a useMemo at 756; if (isLoading) return … is at 776
and the error return at 789.
Verdict: true positive, negligible impact. On the loading and error renders
React still creates one small element object. There is no measurable cost, and
--verbose is what surfaced it.
Confidence: high (that it is harmless). Action: defer. It disappears naturally once the list chrome moves into a child component (see #3, step 2).
8. rn-no-falsy-and-render — order-success.tsx:47
Tool says (error): when the value is 0 this renders a bare 0 and crashes
React Native.
Code:
const totalAmount = params.totalAmount as string
...
{totalAmount && (
<MyText testID="order-success-total" ...>Total: ₹{totalAmount}</MyText>
)}
Verdict: false positive for the crash claim. params comes from
useLocalSearchParams(), so at runtime this is a string (or undefined), not
a number. "0" is truthy, so {totalAmount && <MyText>…} renders the component —
which is the intended UI when the total is genuinely 0 — and the 0 lives inside
<MyText> text, not as a bare child of <View>. An empty string renders nothing.
The bare-0 crash needs a numeric operand, which cannot occur here.
Confidence: high.
Optional hardening (if you don't want to rely on the cast):
{Boolean(totalAmount) && (…)} — same behaviour, silences the rule.
9. rn-list-callback-per-row — search-results/index.tsx:98
Tool says: the onPress is rebuilt for every row, so memoized rows still
redraw.
Code:
renderItem={({ item }) => (
<ProductCard
item={item}
onPress={() => router.push(`/…/product-detail/${item.id}`)}
...
/>
)}
Verdict: true positive — and newly relevant. ProductCard was just wrapped in
React.memo (same batch as the flash work), so this inline onPress is now the
one thing defeating the memo for search results: every render of the list rebuilds
the handler and re-renders every mounted card, each of which re-runs its cart/slot
hooks.
Confidence: high. Suggested fix: extract a memoized row:
const SearchResultItem = memo(({ item, itemWidth, onPress }: …) => {
const handlePress = useCallback(() => onPress(item.id), [item.id, onPress])
return <ProductCard item={item} itemWidth={itemWidth} onPress={handlePress} … />
})
with a stable onPress from the screen (useCallback on router), passed as a
prop. This mirrors FlashProductItem in the flash page.
10. expo-lockfile — package.json
Tool says: multiple lock files detected (package-lock.json, bun.lock);
EAS Build infers the package manager from the lock file, so this is ambiguous.
Verdict: true positive, but repo-level and outside the home folder. Confirmed in the tree:
/bun.lock/package-lock.jsonapps/user-ui/package-lock.json
Confidence: high (the ambiguity exists); medium on which file is canonical.
Action: decide which package manager is authoritative before deleting
anything — package.json scripts and CI config will show which one is actually
used. Not acted on here because it is a packaging decision, not a React fix.
Recommended order (if you want these fixed)
- #5/#6 — derive
hasMore, delete the impure updater. Small, contained, removes both the error and its warning. - #4a — add the two effect dependencies. One line, correctness win.
- #9 — memoized search-result row. Pairs with the
ProductCardmemo already in the tree. - #2 — extract
SectionHeading. Pure presentation, easy review. - #3 / #7 — split
DashboardintouseHomeCatalog+ list chrome. Largest change; do it as its own pass. - #10 — lockfiles: decide, then delete. Separate change, outside React code.
- #1 / #4b / #8 — leave, or silence with a scoped disable and the reasoning above.
Caveats
- React Doctor is deterministic static analysis. It does not measure render counts; it is not a substitute for the render probe or a production trace.
- The scan was path-scoped to this directory, but project-wide rules
(
expo-lockfile) still fire once per project. --categoryonly filters which findings are reported; it does not change which files are scanned.- Fixing #3's effect/state cluster without tests is risky — the pieces listed are
currently covered by the home test suite (
tests/pages/home.test.tsx), so run that suite before and after if this gets picked up.
Reproduce / re-check
# same scope
cd apps/user-ui
npx react-doctor@latest --no-telemetry --blocking none --verbose \
'app/(drawer)/(tabs)/home'
# only what a change introduced (after committing a base)
npx react-doctor@latest --scope changed --base main 'app/(drawer)/(tabs)/home'
# one file
npx react-doctor@latest 'app/(drawer)/(tabs)/home/index.tsx'
# explain one diagnostic
npx react-doctor@latest why 'app/(drawer)/(tabs)/home/index.tsx:590'