Skip to content

Commit 434dc5a

Browse files
fix(home): 去掉 mounted 门控修 CI lint error
react-hooks 7 规则禁止 effect 内同步 setState(set-state-in-effect)。 mounted 门控触发该 error 导致 CI build 挂。改为只用 useReducedMotion—— SSR 首渲染与客户端一致(无 hydration 错配),动效行为不变。
1 parent 31c4dd8 commit 434dc5a

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

app/components/CommunityNetwork.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use client";
22

3-
import { useEffect, useState } from "react";
43
import Image from "next/image";
54
import { ArrowUpRight } from "lucide-react";
65
import { motion, useReducedMotion } from "motion/react";
@@ -18,7 +17,7 @@ type Outpost = {
1817
/**
1918
* 首页"社区网络"版块:三个生态前哨(monitor / mc / openInvest)做成全宽波段,
2019
* 滚动进入视口时错峰升起,hover 时墨色从左漫过整条(反色 wipe)。
21-
* SSR/无 JS/reduced-motion 时直接渲染可见状态(mounted 门控),不把内容藏死
20+
* reduced-motion 时跳过入场动画,直接渲染最终可见状态
2221
*/
2322
export function CommunityNetwork({
2423
label,
@@ -28,9 +27,7 @@ export function CommunityNetwork({
2827
outposts: Outpost[];
2928
}) {
3029
const reduce = useReducedMotion();
31-
const [mounted, setMounted] = useState(false);
32-
useEffect(() => setMounted(true), []);
33-
const animate = mounted && !reduce;
30+
const animate = !reduce;
3431

3532
return (
3633
<div className="mt-16 border-t-4 border-[var(--foreground)] transition-colors duration-300">

0 commit comments

Comments
 (0)