import { uuid as getUuid } from '@/utils';
import { useEffect, useState } from 'react';

function useUuid(uuid?: string): string {
  const [_uuid, setUuid] = useState(uuid ?? getUuid());

  useEffect(() => {
    setUuid(uuid ?? getUuid());
  }, [uuid]);

  return _uuid;
}

export { useUuid };
