mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 14:16:39 +01:00
Need Loader fallbacks
This commit is contained in:
parent
7049166b40
commit
7cac17a043
1 changed files with 8 additions and 2 deletions
|
@ -2,11 +2,13 @@ import { shouldPolyfill } from '@formatjs/intl-segmenter/should-polyfill';
|
|||
import { Suspense } from 'preact/compat';
|
||||
import { useEffect, useState } from 'preact/hooks';
|
||||
|
||||
import Loader from './loader';
|
||||
|
||||
const supportsIntlSegmenter = !shouldPolyfill();
|
||||
|
||||
export default function IntlSegmenterSuspense({ children }) {
|
||||
if (supportsIntlSegmenter) {
|
||||
return <Suspense>{children}</Suspense>;
|
||||
return <Suspense fallback={<Loader />}>{children}</Suspense>;
|
||||
}
|
||||
|
||||
const [polyfillLoaded, setPolyfillLoaded] = useState(false);
|
||||
|
@ -17,5 +19,9 @@ export default function IntlSegmenterSuspense({ children }) {
|
|||
})();
|
||||
}, []);
|
||||
|
||||
return polyfillLoaded && <Suspense>{children}</Suspense>;
|
||||
return polyfillLoaded ? (
|
||||
<Suspense fallback={<Loader />}>{children}</Suspense>
|
||||
) : (
|
||||
<Loader />
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue