Skip to content

Commit 73dbb67

Browse files
committed
chore: reduce nesting of conditions
1 parent bc2cb8b commit 73dbb67

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/components/StickyList.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ function StickyList(
1616
) {
1717
const innerRef = useRef();
1818
useEffect(() => {
19-
if (ref.current && innerRef.current) {
20-
if (mode === 'bottom') {
21-
ref.current.scrollTo(innerRef.current.offsetHeight);
22-
} else if (mode === 'top') {
23-
ref.current.scrollTo(0);
24-
}
19+
if (!ref.current || !innerRef.current) {
20+
return;
21+
}
22+
23+
if (mode === 'bottom') {
24+
ref.current.scrollTo(innerRef.current.offsetHeight);
25+
} else {
26+
ref.current.scrollTo(0);
2527
}
2628
}, [itemCount]);
2729

0 commit comments

Comments
 (0)