fix: Lazily polyfill ResizeObserver for old iOS (#3629)
* fix: Lazily polyfill ResizeObserver for old iOS * fix: Prevent child rendering until polyfills are loaded * tsc
This commit is contained in:
23
app/components/LazyPolyfills.tsx
Normal file
23
app/components/LazyPolyfills.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import * as React from "react";
|
||||
import { loadPolyfills } from "~/utils/polyfills";
|
||||
|
||||
/**
|
||||
* Asyncronously load required polyfills. Should wrap the React tree.
|
||||
*/
|
||||
export const LazyPolyfill: React.FC = ({ children }) => {
|
||||
const [isLoaded, setIsLoaded] = React.useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
loadPolyfills().then(() => {
|
||||
setIsLoaded(true);
|
||||
});
|
||||
}, []);
|
||||
|
||||
if (!isLoaded) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
|
||||
export default LazyPolyfill;
|
||||
Reference in New Issue
Block a user