Skip to content

Commit

Permalink
Clean up discrete event replaying (facebook#26558)
Browse files Browse the repository at this point in the history
We no longer replay and discrete events.

I might re-add a form of this but it'll look a little different.
  • Loading branch information
sebmarkbage authored and AndyPengc12 committed Apr 15, 2024
1 parent e4435b6 commit 354b7b1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {isRootDehydrated} from 'react-reconciler/src/ReactFiberShellHydration';
const {ReactCurrentBatchConfig} = ReactSharedInternals;

// TODO: can we stop exporting these?
export let _enabled: boolean = true;
let _enabled: boolean = true;

// This is exported in FB builds for use by legacy FB layer infra.
// We'd like to remove this but it's not clear if this is safe.
Expand Down
28 changes: 0 additions & 28 deletions packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ type QueuedReplayableEvent = {

let hasScheduledReplayAttempt = false;

// The queue of discrete events to be replayed.
const queuedDiscreteEvents: Array<QueuedReplayableEvent> = [];

// Indicates if any continuous event targets are non-null for early bailout.
const hasAnyQueuedContinuousEvents: boolean = false;
// The last of each continuous event type. We only need to replay the last one
// if the last target was dehydrated.
let queuedFocus: null | QueuedReplayableEvent = null;
Expand All @@ -82,14 +77,6 @@ type QueuedHydrationTarget = {
};
const queuedExplicitHydrationTargets: Array<QueuedHydrationTarget> = [];

export function hasQueuedDiscreteEvents(): boolean {
return queuedDiscreteEvents.length > 0;
}

export function hasQueuedContinuousEvents(): boolean {
return hasAnyQueuedContinuousEvents;
}

const discreteReplayableEvents: Array<DOMEventName> = [
'mousedown',
'mouseup',
Expand Down Expand Up @@ -446,21 +433,6 @@ function scheduleCallbackIfUnblocked(
export function retryIfBlockedOn(
unblocked: Container | SuspenseInstance,
): void {
// Mark anything that was blocked on this as no longer blocked
// and eligible for a replay.
if (queuedDiscreteEvents.length > 0) {
scheduleCallbackIfUnblocked(queuedDiscreteEvents[0], unblocked);
// This is a exponential search for each boundary that commits. I think it's
// worth it because we expect very few discrete events to queue up and once
// we are actually fully unblocked it will be fast to replay them.
for (let i = 1; i < queuedDiscreteEvents.length; i++) {
const queuedEvent = queuedDiscreteEvents[i];
if (queuedEvent.blockedOn === unblocked) {
queuedEvent.blockedOn = null;
}
}
}

if (queuedFocus !== null) {
scheduleCallbackIfUnblocked(queuedFocus, unblocked);
}
Expand Down

0 comments on commit 354b7b1

Please sign in to comment.