mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Currently, in a React 18 root, `act` only works if you mock the Scheduler package. This was because we didn't want to add additional checks at runtime. But now that the `act` testing API is dev-only, we can simplify its implementation. Now when an update is wrapped with `act`, React will bypass Scheduler entirely and push its tasks onto a special internal queue. Then, when the outermost `act` scope exists, we'll flush that queue. I also removed the "wrong act" warning, because the plan is to move `act` to an isomorphic entry point, simlar to `startTransition`. That's not directly related to this PR, but I didn't want to bother re-implementing that warning only to immediately remove it. I'll add the isomorphic API in a follow up. Note that the internal version of `act` that we use in our own tests still depends on mocking the Scheduler package, because it needs to work in production. I'm planning to move that implementation to a shared (internal) module, too.
48 lines
897 B
JavaScript
48 lines
897 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
export {
|
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
act as unstable_act,
|
|
Children,
|
|
Component,
|
|
Fragment,
|
|
Profiler,
|
|
PureComponent,
|
|
StrictMode,
|
|
Suspense,
|
|
SuspenseList,
|
|
cloneElement,
|
|
createContext,
|
|
createElement,
|
|
createFactory,
|
|
createMutableSource as unstable_createMutableSource,
|
|
createRef,
|
|
forwardRef,
|
|
isValidElement,
|
|
lazy,
|
|
memo,
|
|
startTransition,
|
|
unstable_useOpaqueIdentifier,
|
|
useCallback,
|
|
useContext,
|
|
useDebugValue,
|
|
useDeferredValue,
|
|
useEffect,
|
|
useImperativeHandle,
|
|
useLayoutEffect,
|
|
useMemo,
|
|
useMutableSource as unstable_useMutableSource,
|
|
useReducer,
|
|
useRef,
|
|
useState,
|
|
useTransition,
|
|
version,
|
|
} from './src/React';
|