Web Totals

useNavigatorLanguage

import { useEffect, useRef, useState } from 'react';
import * as toxicity from '@tensorflow-models/toxicity';

const subscribe = (onStoreChange) => {
  window.addEventListener('languagechange', onStoreChange);
  return () => window.removeEventListener('languagechange', onStoreChange);
};

const getSnapshot = () => {
  return window.navigator.languages;
};

const useNavigatorLanguage = () => {
  return useSyncExternalStore(subscribe, getSnapshot);
};
jsx