import { useState, useEffect } from 'react';

const useFLoC = () => {
  const [{ id, version }, setState] = useState<{
    id: string | null;
    version: string | null;
  }>({ id: null, version: null });
  useEffect(() => {
    const getCohort = async () => {
      // @ts-ignore
      const cohort = await document.interestCohort();
      setState(cohort);
    };
    getCohort();
  }, []);
  return { id, version };
};

export default useFLoC;
