import * as React from 'react';

export const useBrowser = () => {
  const [browser, setBrowser] = React.useState<string>();
  React.useEffect(() => {
    const isFirefox = typeof (window as unknown as Record<string, unknown>).InstallTrigger !== 'undefined';
    if (isFirefox) {
      setBrowser('firefox');
    } else {
      // TODO - detect other browsers
      setBrowser('chrome');
    }
  }, []);

  return React.useMemo(() => browser, [browser]);
};
