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 useState hook before early return to fix React error #300

Louis Beaumont04b61cd1cda8
diff --git a/apps/screenpipe-app-tauri/components/pipe-store.tsx b/apps/screenpipe-app-tauri/components/pipe-store.tsx
index f1957fb62..e6b947339 100644
--- a/apps/screenpipe-app-tauri/components/pipe-store.tsx
+++ b/apps/screenpipe-app-tauri/components/pipe-store.tsx
@@ -463,6 +463,20 @@ function DiscoverView({ onInstalled }: { onInstalled?: () => void }) {
// Available updates from store
const [availableUpdates, setAvailableUpdates] = useState<Record<string, { latest_version: number; installed_version: number; locally_modified: boolean }>>({});
+ // First-visit banner — show once, dismiss permanently
+ // Initialize false to match server render, set true after mount if not dismissed
+ const [showWelcome, setShowWelcome] = useState(false);
+ useEffect(() => {
+ if (!localStorage.getItem("screenpipe:pipes-welcome-dismissed")) {
+ setShowWelcome(true);
+ }
+ }, []);
+
+ const dismissWelcome = () => {
+ setShowWelcome(false);
+ localStorage.setItem("screenpipe:pipes-welcome-dismissed", "1");
+ };
+
// Fetch installed pipes (cached 30s, invalidated on install)
useEffect(() => {
const cacheKey = "pipes/installed";
@@ -745,20 +759,6 @@ function DiscoverView({ onInstalled }: { onInstalled?: () => void }) {
);
}
- // First-visit banner — show once, dismiss permanently
- // Initialize false to match server render, set true after mount if not dismissed
- const [showWelcome, setShowWelcome] = useState(false);
- useEffect(() => {
- if (!localStorage.getItem("screenpipe:pipes-welcome-dismissed")) {
- setShowWelcome(true);
- }
- }, []);
-
- const dismissWelcome = () => {
- setShowWelcome(false);
- localStorage.setItem("screenpipe:pipes-welcome-dismissed", "1");
- };
-
return (
<div className="space-y-6">
{/* First-visit welcome banner */}