examples/dist/common.js
function resetNextUnitOfWork() {
    // Clear out roots with no more work on them, or if they have uncaught errors
    while (nextScheduledRoot !== null && nextScheduledRoot.current.pendingWorkPriority === NoWork$2) {
      // Unschedule this root.
      nextScheduledRoot.isScheduled = false;
      // Read the next pointer now.
      // We need to clear it in case this root gets scheduled again later.
      var next = nextScheduledRoot.nextScheduledRoot;
      nextScheduledRoot.nextScheduledRoot = null;
      // Exit if we cleared all the roots and there's no work to do.
      if (nextScheduledRoot === lastScheduledRoot) {
        nextScheduledRoot = null;
        lastScheduledRoot = null;
        nextPriorityLevel = NoWork$2;
        return null;
      }
      // Continue with the next root.
      // If there's no work on it, it will get unscheduled too.
      nextScheduledRoot = next;
    }

    var root = nextScheduledRoot;
    var highestPriorityRoot = null;
    var highestPriorityLevel = NoWork$2;
    while (root !== null) {
      if (root.current.pendingWorkPriority !== NoWork$2 && (highestPriorityLevel === NoWork$2 || highestPriorityLevel > root.current.pendingWorkPriority)) {
        highestPriorityLevel = root.current.pendingWorkPriority;
        highestPriorityRoot = root;
      }
      // We didn't find anything to do in this root, so let's try the next one.
      root = root.nextScheduledRoot;
    }
    if (highestPriorityRoot !== null) {
      nextPriorityLevel = highestPriorityLevel;
      // Before we start any new work, let's make sure that we have a fresh
      // stack to work from.
      // TODO: This call is buried a bit too deep. It would be nice to have
      // a single point which happens right before any new work and
      // unfortunately this is it.
      resetContextStack();

      nextUnitOfWork = createWorkInProgress$1(highestPriorityRoot.current, highestPriorityLevel);
      if (highestPriorityRoot !== nextRenderedTree) {
        // We've switched trees. Reset the nested update counter.
        nestedUpdateCount = 0;
        nextRenderedTree = highestPriorityRoot;
      }
      return;
    }

    nextPriorityLevel = NoWork$2;
    nextUnitOfWork = null;
    nextRenderedTree = null;
    return;
  }
function resetNextUnitOfWork() {
    // Clear out roots with no more work on them, or if they have uncaught errors
    while (nextScheduledRoot !== null && nextScheduledRoot.current.pendingWorkPriority === NoWork$2) {
      // Unschedule this root.
      nextScheduledRoot.isScheduled = false;
      // Read the next pointer now.
      // We need to clear it in case this root gets scheduled again later.
      var next = nextScheduledRoot.nextScheduledRoot;
      nextScheduledRoot.nextScheduledRoot = null;
      // Exit if we cleared all the roots and there's no work to do.
      if (nextScheduledRoot === lastScheduledRoot) {
        nextScheduledRoot = null;
        lastScheduledRoot = null;
        nextPriorityLevel = NoWork$2;
        return null;
      }
      // Continue with the next root.
      // If there's no work on it, it will get unscheduled too.
      nextScheduledRoot = next;
    }

    var root = nextScheduledRoot;
    var highestPriorityRoot = null;
    var highestPriorityLevel = NoWork$2;
    while (root !== null) {
      if (root.current.pendingWorkPriority !== NoWork$2 && (highestPriorityLevel === NoWork$2 || highestPriorityLevel > root.current.pendingWorkPriority)) {
        highestPriorityLevel = root.current.pendingWorkPriority;
        highestPriorityRoot = root;
      }
      // We didn't find anything to do in this root, so let's try the next one.
      root = root.nextScheduledRoot;
    }
    if (highestPriorityRoot !== null) {
      nextPriorityLevel = highestPriorityLevel;
      // Before we start any new work, let's make sure that we have a fresh
      // stack to work from.
      // TODO: This call is buried a bit too deep. It would be nice to have
      // a single point which happens right before any new work and
      // unfortunately this is it.
      resetContextStack();

      nextUnitOfWork = createWorkInProgress$1(highestPriorityRoot.current, highestPriorityLevel);
      if (highestPriorityRoot !== nextRenderedTree) {
        // We've switched trees. Reset the nested update counter.
        nestedUpdateCount = 0;
        nextRenderedTree = highestPriorityRoot;
      }
      return;
    }

    nextPriorityLevel = NoWork$2;
    nextUnitOfWork = null;
    nextRenderedTree = null;
    return;
  }
function resetNextUnitOfWork ( ) { // Clear out roots with no more work on them, or if they have uncaught errors while ( nextScheduledRoot !== null && nextScheduledRoot . current . pendingWorkPriority === NoWork$2 ) { // Unschedule this root. nextScheduledRoot . isScheduled = false ; // Read the next pointer now. // We need to clear it in case this root gets scheduled again later. var next = nextScheduledRoot . nextScheduledRoot ; nextScheduledRoot . nextScheduledRoot = null ; // Exit if we cleared all the roots and there's no work to do. if ( nextScheduledRoot === lastScheduledRoot ) { nextScheduledRoot = null ; lastScheduledRoot = null ; nextPriorityLevel = NoWork$2 ; return null ; } // Continue with the next root. // If there's no work on it, it will get unscheduled too. nextScheduledRoot = next ; } var root = nextScheduledRoot ; var highestPriorityRoot = null ; var highestPriorityLevel = NoWork$2 ; while ( root !== null ) { if ( root . current . pendingWorkPriority !== NoWork$2 && ( highestPriorityLevel === NoWork$2 || highestPriorityLevel > root . current . pendingWorkPriority ) ) { highestPriorityLevel = root . current . pendingWorkPriority ; highestPriorityRoot = root ; } // We didn't find anything to do in this root, so let's try the next one. root = root . nextScheduledRoot ; } if ( highestPriorityRoot !== null ) { nextPriorityLevel = highestPriorityLevel ; // Before we start any new work, let's make sure that we have a fresh // stack to work from. // TODO: This call is buried a bit too deep. It would be nice to have // a single point which happens right before any new work and // unfortunately this is it. resetContextStack ( ) ; nextUnitOfWork = createWorkInProgress$1 ( highestPriorityRoot . current , highestPriorityLevel ) ; if ( highestPriorityRoot !== nextRenderedTree ) { // We've switched trees. Reset the nested update counter. nestedUpdateCount = 0 ; nextRenderedTree = highestPriorityRoot ; } return ; } nextPriorityLevel = NoWork$2 ; nextUnitOfWork = null ; nextRenderedTree = null ; return ; }
resetNextUnitOfWork mutates the current priority context. It is reset after after the workLoop exits, so never call resetNextUnitOfWork from outside the work loop.
resetNextUnitOfWork mutates the current priority context . It is reset after after the workLoop exits so never call resetNextUnitOfWork from outside the work loop .