mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
fix: add react v17 useTransition
polyfill (#6618)
This commit is contained in:
parent
fecbde3f5c
commit
13780f390a
2 changed files with 11 additions and 1 deletions
|
@ -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…
Add table
Reference in a new issue