Fix: eliminate reload-only hydration mismatches on home
Make HomePage a server component and mount ActivityFeed via a client-only wrapper to avoid Suspense/dynamic boundary differences between SSR and hydration.
This commit is contained in:
31
app/_ui/ActivityFeedClient.tsx
Normal file
31
app/_ui/ActivityFeedClient.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
type ActivityFeedComponent = React.ComponentType<Record<string, never>>;
|
||||
|
||||
export default function ActivityFeedClient() {
|
||||
const [Comp, setComp] = useState<ActivityFeedComponent | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
(async () => {
|
||||
try {
|
||||
const mod = await import("../components/ActivityFeed");
|
||||
const C = (mod as unknown as { default?: ActivityFeedComponent }).default;
|
||||
if (!cancelled && typeof C === "function") {
|
||||
setComp(() => C);
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
})();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (!Comp) return null;
|
||||
return <Comp />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user