fix: add react v17 useTransition
polyfill (#6618)
This commit is contained in:
parent
fecbde3f5c
commit
13780f390a
@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useMemo, useState, useTransition } from "react";
|
import React, { useEffect, useMemo, useState } from "react";
|
||||||
import { LibraryUnit } from "./LibraryUnit";
|
import { LibraryUnit } from "./LibraryUnit";
|
||||||
import { LibraryItem } from "../types";
|
import { LibraryItem } from "../types";
|
||||||
import Stack from "./Stack";
|
import Stack from "./Stack";
|
||||||
@ -6,6 +6,7 @@ import clsx from "clsx";
|
|||||||
import { ExcalidrawElement, NonDeleted } from "../element/types";
|
import { ExcalidrawElement, NonDeleted } from "../element/types";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { libraryItemSvgsCache } from "../hooks/useLibraryItemSvg";
|
import { libraryItemSvgsCache } from "../hooks/useLibraryItemSvg";
|
||||||
|
import { useTransition } from "../hooks/useTransition";
|
||||||
|
|
||||||
const ITEMS_PER_ROW = 4;
|
const ITEMS_PER_ROW = 4;
|
||||||
const ROWS_RENDERED_PER_BATCH = 6;
|
const ROWS_RENDERED_PER_BATCH = 6;
|
||||||
|
9
src/hooks/useTransition.ts
Normal file
9
src/hooks/useTransition.ts
Normal 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;
|
Loading…
x
Reference in New Issue
Block a user