]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/lexical/core/shared/reactPatches.ts
Lexical: Finished conversion/update of test files
[bookstack] / resources / js / wysiwyg / lexical / core / shared / reactPatches.ts
1 /**
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  *
7  */
8
9 import React from 'react';
10
11 // Webpack + React 17 fails to compile on the usage of `React.startTransition` or
12 // `React["startTransition"]` even if it's behind a feature detection of
13 // `"startTransition" in React`. Moving this to a constant avoids the issue :/
14 const START_TRANSITION = 'startTransition';
15
16 export function startTransition(callback: () => void) {
17   if (START_TRANSITION in React) {
18     React[START_TRANSITION](callback);
19   } else {
20     callback();
21   }
22 }