How to use the scheduler/unstable_mock.unstable_flushAllWithoutAsserting 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 / react / packages / react-noop-renderer / src / createReactNoop.js View on Github external
const rootContainers = new Map();
  const roots = new Map();
  const DEFAULT_ROOT_ID = '';

  const {
    flushPassiveEffects,
    batchedUpdates,
    IsThisRendererActing,
  } = NoopRenderer;

  // this act() implementation should be exactly the same in
  // ReactTestUtilsAct.js, ReactTestRendererAct.js, createReactNoop.js

  const isSchedulerMocked =
    typeof Scheduler.unstable_flushAllWithoutAsserting === 'function';
  const flushWork =
    Scheduler.unstable_flushAllWithoutAsserting ||
    function() {
      let didFlushWork = false;
      while (flushPassiveEffects()) {
        didFlushWork = true;
      }

      return didFlushWork;
    };

  function flushWorkAndMicroTasks(onDone: (err: ?Error) => void) {
    try {
      flushWork();
      enqueueTask(() => {
        if (flushWork()) {
github facebook / react / packages / react-noop-renderer / src / createReactNoop.js View on Github external
const roots = new Map();
  const DEFAULT_ROOT_ID = '';

  const {
    flushPassiveEffects,
    batchedUpdates,
    IsThisRendererActing,
  } = NoopRenderer;

  // this act() implementation should be exactly the same in
  // ReactTestUtilsAct.js, ReactTestRendererAct.js, createReactNoop.js

  const isSchedulerMocked =
    typeof Scheduler.unstable_flushAllWithoutAsserting === 'function';
  const flushWork =
    Scheduler.unstable_flushAllWithoutAsserting ||
    function() {
      let didFlushWork = false;
      while (flushPassiveEffects()) {
        didFlushWork = true;
      }

      return didFlushWork;
    };

  function flushWorkAndMicroTasks(onDone: (err: ?Error) => void) {
    try {
      flushWork();
      enqueueTask(() => {
        if (flushWork()) {
          flushWorkAndMicroTasks(onDone);
        } else {