Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

476 B
Raw Blame
import { useEffect, useState } from 'react';

import { isOnServerSide } from '@/utils/env';

export const SCROLL_PARENT_ID = 'memory-scroll';

export const useScrollParent = () => {
  const [parent, setParent] = useState<HTMLDivElement>();

  useEffect(() => {
    if (isOnServerSide) return;
    const scrollParent = document.querySelector(`#${SCROLL_PARENT_ID}`);
    if (scrollParent) {
      setParent(scrollParent as HTMLDivElement);
    }
  }, []);

  return parent;
};