Skip to content

Commit

Permalink
Merge branch 'main' into fix/exhaustive-deps-ts-as
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleShit authored Feb 1, 2024
2 parents 6129f47 + 53b12e4 commit aa068d1
Show file tree
Hide file tree
Showing 18 changed files with 26 additions and 20 deletions.
4 changes: 2 additions & 2 deletions fixtures/dom/src/__tests__/nested-act-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('unmocked scheduler', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
DOMAct = React.unstable_act;
DOMAct = React.act;
TestRenderer = require('react-test-renderer');
TestAct = TestRenderer.act;
});
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('mocked scheduler', () => {
require.requireActual('scheduler/unstable_mock')
);
React = require('react');
DOMAct = React.unstable_act;
DOMAct = React.act;
TestRenderer = require('react-test-renderer');
TestAct = TestRenderer.act;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ describe('Store component filters', () => {
let utils;

const act = async (callback: Function) => {
if (React.unstable_act != null) {
if (React.act != null) {
await React.act(callback);
} else if (React.unstable_act != null) {
await React.unstable_act(callback);
} else {
callback();
Expand Down
4 changes: 3 additions & 1 deletion packages/react-devtools-shared/src/__tests__/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export function act(
const {act: actTestRenderer} = require('react-test-renderer');
// Use `require('react-dom/test-utils').act` as a fallback for React 17, which can be used in integration tests for React DevTools.
const actDOM =
require('react').unstable_act || require('react-dom/test-utils').act;
require('react').act ||
require('react').unstable_act ||
require('react-dom/test-utils').act;

actDOM(() => {
actTestRenderer(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('ReactDOMServerHydration', () => {
React = require('react');
ReactDOMClient = require('react-dom/client');
ReactDOMServer = require('react-dom/server');
act = React.unstable_act;
act = React.act;

console.error = jest.fn();
container = document.createElement('div');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ beforeEach(() => {
yields = [];
React = require('react');
ReactDOMClient = require('react-dom/client');
act = React.unstable_act;
act = React.act;
container = document.createElement('div');
document.body.appendChild(container);
});
Expand Down
4 changes: 3 additions & 1 deletion packages/react-dom/src/test-utils/ReactTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ const getFiberCurrentPropsFromNode = EventInternals[2];
const enqueueStateRestore = EventInternals[3];
const restoreStateIfNeeded = EventInternals[4];

const act = React.unstable_act;
// TODO: Add a warning if this API is accessed with advice to switch to
// importing directly from the React package instead.
const act = React.act;

function Event(suffix) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('act warnings', () => {
React = require('react');
Scheduler = require('scheduler');
ReactNoop = require('react-noop-renderer');
act = React.unstable_act;
act = React.act;
useState = React.useState;
Suspense = React.Suspense;
startTransition = React.startTransition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('ReactFiberHostContext', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
act = React.unstable_act;
act = React.act;
ReactFiberReconciler = require('react-reconciler');
ConcurrentRoot =
require('react-reconciler/src/ReactRootTags').ConcurrentRoot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('isomorphic act()', () => {
ReactNoop = require('react-noop-renderer');
DiscreteEventPriority =
require('react-reconciler/constants').DiscreteEventPriority;
act = React.unstable_act;
act = React.act;
use = React.use;
Suspense = React.Suspense;
startTransition = React.startTransition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ describe('`act` bypasses Scheduler methods completely,', () => {
}

const root = ReactNoop.createRoot();
const publicAct = React.unstable_act;
const publicAct = React.act;
const prevIsReactActEnvironment = global.IS_REACT_ACT_ENVIRONMENT;
try {
global.IS_REACT_ACT_ENVIRONMENT = true;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-refresh/src/__tests__/ReactFresh-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('ReactFresh', () => {
ReactDOM = require('react-dom');
ReactDOMClient = require('react-dom/client');
Scheduler = require('scheduler');
act = React.unstable_act;
act = React.act;
internalAct = require('internal-test-utils').act;

const InternalTestUtils = require('internal-test-utils');
Expand Down Expand Up @@ -3792,7 +3792,7 @@ describe('ReactFresh', () => {
React = require('react');
ReactDOM = require('react-dom');
Scheduler = require('scheduler');
act = React.unstable_act;
act = React.act;
internalAct = require('internal-test-utils').act;

// Important! Inject into the global hook *after* ReactDOM runs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('ReactFlightDOMForm', () => {
ReactServerDOMClient = require('react-server-dom-webpack/client.edge');
ReactDOMServer = require('react-dom/server.edge');
ReactDOMClient = require('react-dom/client');
act = React.unstable_act;
act = React.act;
useFormState = require('react-dom').useFormState;
container = document.createElement('div');
document.body.appendChild(container);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-test-renderer/src/ReactTestRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import {getPublicInstance} from './ReactFiberConfigTestHost';
import {ConcurrentRoot, LegacyRoot} from 'react-reconciler/src/ReactRootTags';
import {allowConcurrentByDefault} from 'shared/ReactFeatureFlags';

const act = React.unstable_act;
const act = React.act;

// TODO: Remove from public bundle

Expand Down
2 changes: 1 addition & 1 deletion packages/react/index.classic.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

export {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
act as unstable_act,
act,
Children,
Component,
Fragment,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/index.experimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

export {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
act as unstable_act,
act,
Children,
Component,
Fragment,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type ChildrenArray<+T> = $ReadOnlyArray<ChildrenArray<T>> | T;
// We can't use export * from in Flow for some reason.
export {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
act as unstable_act,
act,
Children,
Component,
Fragment,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/index.modern.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

export {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
act as unstable_act,
act,
Children,
Component,
Fragment,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/index.stable.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

export {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
act as unstable_act,
act,
Children,
Component,
Fragment,
Expand Down

0 comments on commit aa068d1

Please sign in to comment.