react-fiber-architecture icon indicating copy to clipboard operation
react-fiber-architecture copied to clipboard

PriorityLevel module no longer being used in Fiber

Open reccanti opened this issue 7 years ago • 3 comments

It looks like the ReactPriorityLevel module was removed as of this commit. It looks like at least the link in the pendingWorkPriority section should be updated to reflect that. Is there anything else in that section that should be removed?

reccanti avatar Jan 25 '18 04:01 reccanti

Hey @acdlite. Thank you for the detailed write up. 😃✋As @reccanti mentioned, ReactPriorityLevel is either absent or has been moved into a different module in the react codebase. Could you point how to fix this? I think this is minor and can be quickly resolved. Thanks again! 😄

onstash avatar Mar 13 '18 16:03 onstash

Based on my understanding (I can be wrong) it looks like the concept of priorities is gone for now. Instead we have "Sync" and "Async" units of work.

If you look at the workLoop function we have:

function workLoop(isAsync) {
    if (!isAsync) {
      // Flush all expired work.
      while (nextUnitOfWork !== null) {
        nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
      }
    } else {
      // Flush asynchronous work until the deadline runs out of time.
      while (nextUnitOfWork !== null && !shouldYield()) {
        nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
      }
    }
  }

So basically render everything right away if we're dealing with a regular update, or if it's an async update render it if we have the time to do so. shouldYield checks if we have enough time to render the current unitOfWork.

poxrud avatar May 10 '18 20:05 poxrud

You can find the different types of levels here though (if I understood the document correctly):

https://github.com/facebook/react/blob/8c67bbf183cc5ae1cab15a8265c612daf80cd86f/packages/scheduler/src/Scheduler.js#L12

FredrikAugust avatar Nov 05 '18 13:11 FredrikAugust