Skip to content

Commit b6b0b20

Browse files
committed
Refactor SlidingTextBox: move contentBox declaration to the top of the initialize function
1 parent 2aa1741 commit b6b0b20

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/components/SlidingTextBox.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { useEffect, useRef } from "react";
22
import styles from "./SlidingTextBox.module.css";
33

44
const initialize = (containerBox: HTMLElement) => {
5+
const contentBox = containerBox.querySelector<HTMLElement>("." + styles.contentBox);
6+
57
const resizeObserver = new ResizeObserver((_) => {
68
containerBox.style.minHeight = contentBox?.scrollHeight + "px";
79
});
810

9-
const contentBox = containerBox.querySelector<HTMLElement>("." + styles.contentBox);
1011
if (contentBox) resizeObserver.observe(contentBox);
1112

1213
return {

0 commit comments

Comments
 (0)