Skip to content
Closed
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
35 changes: 32 additions & 3 deletions packages/react-native-renderer/src/ReactFiberConfigFabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,43 @@
return DefaultEventPriority;
}

export function trackSchedulerEvent(): void {}
let schedulerEvent: void | Event = undefined;
export function trackSchedulerEvent(): void {
schedulerEvent = global.event;
}

function getEventType(event: Event): null | string {
if (event.type) {
return event.type;
}

// Legacy implementation. RN does not define the `type` property on the event object yet.
// $FlowExpectedError[prop-missing]
const dispatchConfig = event.dispatchConfig;
if (dispatchConfig == null || dispatchConfig.phasedRegistrationNames == null) {
return null;
}

const rawEventType = dispatchConfig.phasedRegistrationNames.bubbled || dispatchConfig.phasedRegistrationNames.captured;
if (!rawEventType) {
return null;
}

if (rawEventType.startsWith('on')) {
return rawEventType.substring(2).toLowerCase();

Check failure on line 448 in packages/react-native-renderer/src/ReactFiberConfigFabric.js

View workflow job for this annotation

GitHub Actions / Run eslint

Prefer string.slice() over .substring() and .substr()
}

return rawEventType.toLowerCase();
}

export function resolveEventType(): null | string {
return null;
const event = global.event;
return event && event !== schedulerEvent ? getEventType(event) : null;
}

export function resolveEventTimeStamp(): number {
return -1.1;
const event = global.event;
return event && event !== schedulerEvent ? event.timeStamp : -1.1;
}

export function shouldAttemptEagerTransition(): boolean {
Expand Down
Loading