Skip to content

Commit 760f83b

Browse files
authoredJan 22, 2025··
fix(landing): invalid isMounted judgment (#1238)
1 parent b6696cf commit 760f83b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

‎website/landing/components/Hero/HeroDesktop/HeroDesktop.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const HeroDesktop: React.FC = () => {
2222
const [scrollPosition, setScrollPosition] = useState(scrollY.get());
2323
const scrollHeight = useMemo(() => sectionHeight / 3, [sectionHeight]);
2424
const [animationComplete, setAnimationComplete] = useState(false);
25-
const isMounted = useRef(false);
25+
const isMountedRef = useRef(false);
2626

2727
scrollY.onChange((updatedScroll) => setScrollPosition(updatedScroll));
2828

@@ -102,9 +102,9 @@ export const HeroDesktop: React.FC = () => {
102102
}, [sectionRef]);
103103

104104
useLayoutEffect(() => {
105-
if (isMounted.current) return;
105+
if (isMountedRef.current) return;
106106

107-
isMounted.current = !!sectionRef.current;
107+
isMountedRef.current = !!sectionRef.current;
108108
}, [sectionRef]);
109109

110110
useEffect(() => {
@@ -154,6 +154,8 @@ export const HeroDesktop: React.FC = () => {
154154
// eslint-disable-next-line react-hooks/exhaustive-deps
155155
}, [animationComplete]);
156156

157+
const isMounted = isMountedRef.current;
158+
157159
return (
158160
<AnimatedBox
159161
ref={sectionRef}
@@ -180,7 +182,7 @@ export const HeroDesktop: React.FC = () => {
180182
position: "sticky",
181183
top: 0,
182184
transform: "scale($container-scale)",
183-
opacity: isMounted.current ? 1 : 0,
185+
opacity: isMounted ? 1 : 0,
184186
transition: "opacity 300ms linear",
185187

186188
display: "flex",

0 commit comments

Comments
 (0)
Please sign in to comment.