Preload IntlSegmenter polyfill if needed

pull/475/head
Lim Chee Aun 2024-04-03 14:33:53 +08:00
rodzic 5246af4ae9
commit ebd9f05f69
1 zmienionych plików z 9 dodań i 0 usunięć

Wyświetl plik

@ -6,6 +6,15 @@ import Loader from './loader';
const supportsIntlSegmenter = !shouldPolyfill();
// Preload IntlSegmenter
setTimeout(() => {
queueMicrotask(() => {
if (!supportsIntlSegmenter) {
import('@formatjs/intl-segmenter/polyfill-force').catch(() => {});
}
});
}, 1000);
export default function IntlSegmenterSuspense({ children }) {
if (supportsIntlSegmenter) {
return <Suspense fallback={<Loader />}>{children}</Suspense>;