trails/apps/planner/app/components/ClientOnly.tsx
Ullrich Schäfer e40b7dc199
Fix SSR and automerge timing
SSR fix:
- ClientOnly wrapper prevents Leaflet/Yjs from running during SSR
- SessionView lazy-loaded to avoid browser API usage on server

Automerge fix:
- Set MERGE_READY_STATE to 'clean' only (was including 'unstable')
- Prevents merging before all CI checks complete

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 00:49:54 +01:00

17 lines
346 B
TypeScript

import { useState, useEffect, type ReactNode } from "react";
export function ClientOnly({
children,
fallback = null,
}: {
children: () => ReactNode;
fallback?: ReactNode;
}) {
const [mounted, setMounted] = useState(false);
useEffect(() => {
setMounted(true);
}, []);
return mounted ? <>{children()}</> : <>{fallback}</>;
}