fix: add react v17 useTransition polyfill (#6618)

This commit is contained in:
David Luzar 2023-05-24 17:24:54 +02:00 committed by GitHub
parent fecbde3f5c
commit 13780f390a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -0,0 +1,9 @@
import React, { useCallback } from "react";
/** noop polyfill for v17. Subset of API available */
function useTransitionPolyfill() {
const startTransition = useCallback((callback: () => void) => callback(), []);
return [false, startTransition] as const;
}
export const useTransition = React.useTransition || useTransitionPolyfill;