import {
  useEffect, useHost, useRef, useState,
} from "atomico";

export function useDocumentTitleHook(title: string, retainOnUnmount = false) {
  const defaultTitle = useRef(document.title);

  useEffect(() => {
    document.title = title;

    return () => {
      if (!retainOnUnmount) document.title = defaultTitle.current;
    };
  }, [title]);
}
