How to use the scheduler.unstable_getCurrentPriorityLevel function in scheduler

To help you get started, weโ€™ve selected a few scheduler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook / relay / packages / relay-experimental / useRefetchableFragmentNode.js View on Github external
// has unmounted
      if (isMountedRef.current !== true) {
        warning(
          false,
          'Relay: Unexpected call to `refetch` on unmounted component for fragment ' +
            '`%s` in `%s`. It looks like some instances of your component are ' +
            'still trying to fetch data but they already unmounted. ' +
            'Please make sure you clear all timers, intervals, ' +
            'async calls, etc that may trigger a fetch.',
          fragmentNode.name,
          componentDisplayName,
        );
        return {dispose: () => {}};
      }
      if (
        Scheduler.unstable_getCurrentPriorityLevel() <
        Scheduler.unstable_NormalPriority
      ) {
        warning(
          false,
          'Relay: Unexpected call to `refetch` at a priority higher than ' +
            'expected on fragment `%s` in `%s`. It looks like you tried to ' +
            'call `refetch` under a high priority update, but updates that ' +
            'can cause the component to suspend should be scheduled at ' +
            'normal priority. Make sure you are calling `refetch` inside ' +
            '`startTransition()` from the `useSuspenseTransition()` hook.',
          fragmentNode.name,
          componentDisplayName,
        );
      }
      if (parentFragmentRef == null) {
        warning(
github facebook / relay / packages / relay-experimental / useBlockingPaginationFragment.js View on Github external
(...callArgs) => {
      if (
        Scheduler.unstable_getCurrentPriorityLevel() <
        Scheduler.unstable_NormalPriority
      ) {
        warning(
          false,
          'Relay: Unexpected call to `%s` at a priority higher than ' +
            'expected on fragment `%s` in `%s`. It looks like you tried to ' +
            'call `refetch` under a high priority update, but updates that ' +
            'can cause the component to suspend should be scheduled at ' +
            'normal priority. Make sure you are calling `refetch` inside ' +
            '`startTransition()` from the `useSuspenseTransition()` hook.',
          args.direction === 'forward' ? 'loadNext' : 'loadPrevious',
          args.fragmentNode.name,
          args.componentDisplayName,
        );
      }
github facebook / react / packages / react-dom / src / events / ReactDOMEventReplaying.js View on Github external
export function queueExplicitHydrationTarget(target: Node): void {
  if (enableSelectiveHydration) {
    let priority = getCurrentPriorityLevel();
    const queuedTarget: QueuedHydrationTarget = {
      blockedOn: null,
      target: target,
      priority: priority,
    };
    let i = 0;
    for (; i < queuedExplicitHydrationTargets.length; i++) {
      if (priority <= queuedExplicitHydrationTargets[i].priority) {
        break;
      }
    }
    queuedExplicitHydrationTargets.splice(i, 0, queuedTarget);
    if (i === 0) {
      attemptExplicitHydrationTarget(queuedTarget);
    }
  }