Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: move useMemo before early return to fix "fewer hooks" crash in Discover

Louis Beaumont8ca1743b8e9b
diff --git a/apps/screenpipe-app-tauri/components/pipe-store.tsx b/apps/screenpipe-app-tauri/components/pipe-store.tsx
index f674015c9..a5a92c0c5 100644
--- a/apps/screenpipe-app-tauri/components/pipe-store.tsx
+++ b/apps/screenpipe-app-tauri/components/pipe-store.tsx
@@ -568,6 +568,17 @@ function DiscoverView() {
}
};
+ // Client-side category filter (must be before any early returns to keep hook count stable)
+ const filteredPipes = useMemo(() => {
+ if (category === "All") return pipes;
+ return pipes.filter((p) => {
+ const cat = (p.category || "other").charAt(0).toUpperCase() + (p.category || "other").slice(1);
+ return cat === category;
+ });
+ }, [pipes, category]);
+
+ const featuredPipes = filteredPipes.filter((p) => p.featured);
+
// If showing detail view, render full-width detail panel
if (showDetail) {
return (
@@ -616,17 +627,6 @@ function DiscoverView() {
);
}
- // Client-side category filter
- const filteredPipes = useMemo(() => {
- if (category === "All") return pipes;
- return pipes.filter((p) => {
- const cat = (p.category || "other").charAt(0).toUpperCase() + (p.category || "other").slice(1);
- return cat === category;
- });
- }, [pipes, category]);
-
- const featuredPipes = filteredPipes.filter((p) => p.featured);
-
return (
<div className="space-y-6">
{/* Header */}