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

@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useState, useTransition } from "react";
import React, { useEffect, useMemo, useState } from "react";
import { LibraryUnit } from "./LibraryUnit";
import { LibraryItem } from "../types";
import Stack from "./Stack";
@ -6,6 +6,7 @@ import clsx from "clsx";
import { ExcalidrawElement, NonDeleted } from "../element/types";
import { useAtom } from "jotai";
import { libraryItemSvgsCache } from "../hooks/useLibraryItemSvg";
import { useTransition } from "../hooks/useTransition";
const ITEMS_PER_ROW = 4;
const ROWS_RENDERED_PER_BATCH = 6;

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;