import { useLayoutEffect, useState } from "react";

export const useAppVersion = () => {
  const [appVersion, setAppVersion] = useState('');
  useLayoutEffect(() => {
    const src = document.querySelector('head > script')?.getAttribute('src') ?? '';
    const version = /\b(?<ver>\w*).js/.exec(src)?.groups?.ver ?? '';
    setAppVersion(version.toUpperCase());
  }, []);
  return appVersion;
}