Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-dev builds in development environment #32341

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/react-reconciler/src/ReactFiberAct.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ export function isConcurrentActEnvironment(): void | boolean {
IS_REACT_ACT_ENVIRONMENT
: undefined;

if (
!isReactActEnvironmentGlobal &&
ReactSharedInternals.actQueue !== null
) {
if (!isReactActEnvironmentGlobal && ReactSharedInternals.actQueue) {
// TODO: Include link to relevant documentation page.
console.error(
'The current testing environment is not configured to support ' +
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberErrorLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function logUncaughtError(
errorBoundaryName = null;
}
const error = (errorInfo.value: any);
if (__DEV__ && ReactSharedInternals.actQueue !== null) {
if (__DEV__ && ReactSharedInternals.actQueue) {
// For uncaught errors inside act, we track them on the act and then
// rethrow them into the test.
ReactSharedInternals.thrownErrors.push(error);
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberRootScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function ensureRootIsScheduled(root: FiberRoot): void {

// At the end of the current event, go through each of the roots and ensure
// there's a task scheduled for each one at the correct priority.
if (__DEV__ && ReactSharedInternals.actQueue !== null) {
if (__DEV__ && ReactSharedInternals.actQueue) {
// We're inside an `act` scope.
if (!didScheduleMicrotask_act) {
didScheduleMicrotask_act = true;
Expand Down Expand Up @@ -394,7 +394,7 @@ function scheduleTaskForRootDuringMicrotask(
// on the `act` queue.
!(
__DEV__ &&
ReactSharedInternals.actQueue !== null &&
ReactSharedInternals.actQueue &&
existingCallbackNode !== fakeActCallbackNode
)
) {
Expand Down Expand Up @@ -555,7 +555,7 @@ function scheduleCallback(
priorityLevel: PriorityLevel,
callback: RenderTaskFn,
) {
if (__DEV__ && ReactSharedInternals.actQueue !== null) {
if (__DEV__ && ReactSharedInternals.actQueue) {
// Special case: We're inside an `act` scope (a testing utility).
// Instead of scheduling work in the host environment, add it to a
// fake internal queue that's managed by the `act` implementation.
Expand All @@ -576,7 +576,7 @@ function cancelCallback(callbackNode: mixed) {
}

function scheduleImmediateRootScheduleTask() {
if (__DEV__ && ReactSharedInternals.actQueue !== null) {
if (__DEV__ && ReactSharedInternals.actQueue) {
// Special case: Inside an `act` scope, we push microtasks to the fake `act`
// callback queue. This is because we currently support calling `act`
// without awaiting the result. The plan is to deprecate that, and require
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberThenable.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function trackUsedThenable<T>(
thenable: Thenable<T>,
index: number,
): T {
if (__DEV__ && ReactSharedInternals.actQueue !== null) {
if (__DEV__ && ReactSharedInternals.actQueue) {
ReactSharedInternals.didUsePromise = true;
}
const trackedThenables = getThenablesFromState(thenableState);
Expand Down
6 changes: 3 additions & 3 deletions packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -2677,7 +2677,7 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes) {
}
}

if (__DEV__ && ReactSharedInternals.actQueue !== null) {
if (__DEV__ && ReactSharedInternals.actQueue) {
// `act` special case: If we're inside an `act` scope, don't consult
// `shouldYield`. Always keep working until the render is complete.
// This is not just an optimization: in a unit test environment, we
Expand Down Expand Up @@ -4637,7 +4637,7 @@ function scheduleCallback(priorityLevel: any, callback) {
// If we're currently inside an `act` scope, bypass Scheduler and push to
// the `act` queue instead.
const actQueue = ReactSharedInternals.actQueue;
if (actQueue !== null) {
if (actQueue) {
actQueue.push(callback);
return fakeActCallbackNode;
} else {
Expand All @@ -4651,7 +4651,7 @@ function scheduleCallback(priorityLevel: any, callback) {

function shouldForceFlushFallbacksInDEV() {
// Never force flush in production. This function should get stripped out.
return __DEV__ && ReactSharedInternals.actQueue !== null;
return __DEV__ && !!ReactSharedInternals.actQueue;
}

function warnIfUpdatesNotWrappedWithActDEV(fiber: Fiber): void {
Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/ReactAct.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ export function act<T>(callback: () => T | Thenable<T>): Thenable<T> {
const prevActQueue = ReactSharedInternals.actQueue;
const prevActScopeDepth = actScopeDepth;
actScopeDepth++;
const queue = (ReactSharedInternals.actQueue =
prevActQueue !== null ? prevActQueue : []);
const queue = (ReactSharedInternals.actQueue = prevActQueue
? prevActQueue
: []);
// Used to reproduce behavior of `batchedUpdates` in legacy mode. Only
// set to `true` while the given callback is executed, not for updates
// triggered during an async event, because this is how the legacy
Expand Down