# 1. Start the app
cd react-app && npm run dev
# 2. Open browser at http://localhost:3000
# 3. Open DevTools Console (F12)
# 4. Navigate to Kits page
# 5. Click a kit button
# 6. Watch console logs[KIT] Kit button clicked: kitId= 1
[STATE] selectedKit changed: {newValue: 1}
[PADGRID] Component MOUNTED
[SAMPLEBROWSER] Component MOUNTED
(No unmount happens)
[KIT] Kit button clicked: kitId= 1
[PADGRID] Component MOUNTED
... 1-2 seconds later ...
[STATE] WARNING: selectedKit is undefined! 👈 ROOT CAUSE
[PADGRID] Component UNMOUNTING
-
The moment you click the kit button
- Look for:
[KIT] Kit button clicked
- Look for:
-
When selectedKit becomes undefined
- Look for:
[STATE] WARNING: selectedKit is undefined!
- Look for:
-
What happened RIGHT BEFORE selectedKit became undefined
- Usually 2-3 lines above the WARNING
- Look for:
[MUTATION]or[QUERY]entries
-
The exact unmount log
- Look for:
[PADGRID] Component UNMOUNTING
- Look for:
- App is running on http://localhost:3000
- Browser console is open and cleared
- You can see the Kits page
- There are kits available to click
- You clicked a kit button
- You watched the console for 5 seconds after clicking
- You captured/screenshot the console logs
Copy/paste the entire console log output starting from:
[KIT] Kit button clicked...
Through to:
[PADGRID] Component UNMOUNTING...
Include timestamps to show the delay between events.
If you see the pattern above, the fix is likely:
File: /react-app/src/hooks/useKits.ts
Change: In useAssignSample, useRemoveSample, and useCreateKit, replace:
queryClient.invalidateQueries({ queryKey: queryKeys.kits.lists() });With:
// Don't invalidate the list - use optimistic update instead
// This prevents the kits data from temporarily becoming undefinedOr add placeholderData to preserve old data during refetch:
// In useKits hook
export function useKits(params?: { skip?: number; limit?: number }) {
return useQuery({
queryKey: queryKeys.kits.list(params),
queryFn: () => kitsApi.list(params),
placeholderData: (previousData) => previousData, // 👈 ADD THIS
});
}If you see different log patterns than described above, capture the full console output and we'll analyze the actual sequence of events.