How to use the scheduler.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-test-renderer / src / ReactTestRendererAct.js View on Github external
import {
  batchedUpdates,
  flushPassiveEffects,
  IsThisRendererActing,
} from 'react-reconciler/inline.test';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import enqueueTask from 'shared/enqueueTask';
import * as Scheduler from 'scheduler';

const {IsSomeRendererActing} = ReactSharedInternals;

// this 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 makuga01 / dnsFookup / FE / node_modules / react-dom / cjs / react-dom-test-utils.development.js View on Github external
eventNameDispatchConfigs = _ReactDOM$__SECRET_IN[4],
    accumulateTwoPhaseDispatches = _ReactDOM$__SECRET_IN[5],
    accumulateDirectDispatches = _ReactDOM$__SECRET_IN[6],
    enqueueStateRestore = _ReactDOM$__SECRET_IN[7],
    restoreStateIfNeeded = _ReactDOM$__SECRET_IN[8],
    dispatchEvent = _ReactDOM$__SECRET_IN[9],
    runEventsInBatch = _ReactDOM$__SECRET_IN[10],

/* eslint-enable no-unused-vars */
flushPassiveEffects = _ReactDOM$__SECRET_IN[11],
    IsThisRendererActing = _ReactDOM$__SECRET_IN[12];
var batchedUpdates = ReactDOM.unstable_batchedUpdates;
var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; // this implementation should be exactly the same in
// ReactTestUtilsAct.js, ReactTestRendererAct.js, createReactNoop.js

var isSchedulerMocked = typeof Scheduler.unstable_flushAllWithoutAsserting === 'function';

var flushWork = Scheduler.unstable_flushAllWithoutAsserting || function () {
  var didFlushWork = false;

  while (flushPassiveEffects()) {
    didFlushWork = true;
  }

  return didFlushWork;
};

function flushWorkAndMicroTasks(onDone) {
  try {
    flushWork();
    enqueueTask(function () {
      if (flushWork()) {
github makuga01 / dnsFookup / FE / node_modules / react-dom / cjs / react-dom-test-utils.development.js View on Github external
accumulateDirectDispatches = _ReactDOM$__SECRET_IN[6],
    enqueueStateRestore = _ReactDOM$__SECRET_IN[7],
    restoreStateIfNeeded = _ReactDOM$__SECRET_IN[8],
    dispatchEvent = _ReactDOM$__SECRET_IN[9],
    runEventsInBatch = _ReactDOM$__SECRET_IN[10],

/* eslint-enable no-unused-vars */
flushPassiveEffects = _ReactDOM$__SECRET_IN[11],
    IsThisRendererActing = _ReactDOM$__SECRET_IN[12];
var batchedUpdates = ReactDOM.unstable_batchedUpdates;
var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; // this implementation should be exactly the same in
// ReactTestUtilsAct.js, ReactTestRendererAct.js, createReactNoop.js

var isSchedulerMocked = typeof Scheduler.unstable_flushAllWithoutAsserting === 'function';

var flushWork = Scheduler.unstable_flushAllWithoutAsserting || function () {
  var didFlushWork = false;

  while (flushPassiveEffects()) {
    didFlushWork = true;
  }

  return didFlushWork;
};

function flushWorkAndMicroTasks(onDone) {
  try {
    flushWork();
    enqueueTask(function () {
      if (flushWork()) {
        flushWorkAndMicroTasks(onDone);
      } else {
github facebook / react / packages / react-dom / src / test-utils / ReactTestUtilsAct.js View on Github external
dispatchEvent,
  runEventsInBatch,
  /* eslint-enable no-unused-vars */
  flushPassiveEffects,
  IsThisRendererActing,
] = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;

const batchedUpdates = ReactDOM.unstable_batchedUpdates;

const {IsSomeRendererActing} = ReactSharedInternals;

// this 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-test-renderer / src / ReactTestRendererAct.js View on Github external
flushPassiveEffects,
  IsThisRendererActing,
} from 'react-reconciler/inline.test';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import enqueueTask from 'shared/enqueueTask';
import * as Scheduler from 'scheduler';

const {IsSomeRendererActing} = ReactSharedInternals;

// this 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 {
github polakowo / datadocs / website / node_modules / react-dom / cjs / react-dom-test-utils.development.js View on Github external
var eventNameDispatchConfigs$1 = _ReactDOM$__SECRET_IN$1[4];
var accumulateTwoPhaseDispatches$1 = _ReactDOM$__SECRET_IN$1[5];
var accumulateDirectDispatches$1 = _ReactDOM$__SECRET_IN$1[6];
var enqueueStateRestore$1 = _ReactDOM$__SECRET_IN$1[7];
var restoreStateIfNeeded$1 = _ReactDOM$__SECRET_IN$1[8];
var dispatchEvent$1 = _ReactDOM$__SECRET_IN$1[9];
var runEventsInBatch$1 = _ReactDOM$__SECRET_IN$1[10];
var flushPassiveEffects$1 = _ReactDOM$__SECRET_IN$1[11];
var IsThisRendererActing$1 = _ReactDOM$__SECRET_IN$1[12];
var batchedUpdates = ReactDOM.unstable_batchedUpdates;
var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; // this implementation should be exactly the same in
// ReactTestUtilsAct.js, ReactTestRendererAct.js, createReactNoop.js

var isSchedulerMocked = typeof Scheduler.unstable_flushAllWithoutAsserting === 'function';

var flushWork = Scheduler.unstable_flushAllWithoutAsserting || function () {
  var didFlushWork = false;

  while (flushPassiveEffects$1()) {
    didFlushWork = true;
  }

  return didFlushWork;
};

function flushWorkAndMicroTasks(onDone) {
  try {
    flushWork();
    enqueueTask$1(function () {
      if (flushWork()) {
        flushWorkAndMicroTasks(onDone);
      } else {
github facebook / react / packages / react-dom / src / test-utils / ReactTestUtilsAct.js View on Github external
/* eslint-enable no-unused-vars */
  flushPassiveEffects,
  IsThisRendererActing,
] = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;

const batchedUpdates = ReactDOM.unstable_batchedUpdates;

const {IsSomeRendererActing} = ReactSharedInternals;

// this 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 {
github polakowo / datadocs / website / node_modules / react-dom / cjs / react-dom-test-utils.development.js View on Github external
var getFiberCurrentPropsFromNode$1 = _ReactDOM$__SECRET_IN$1[2];
var injectEventPluginsByName$1 = _ReactDOM$__SECRET_IN$1[3];
var eventNameDispatchConfigs$1 = _ReactDOM$__SECRET_IN$1[4];
var accumulateTwoPhaseDispatches$1 = _ReactDOM$__SECRET_IN$1[5];
var accumulateDirectDispatches$1 = _ReactDOM$__SECRET_IN$1[6];
var enqueueStateRestore$1 = _ReactDOM$__SECRET_IN$1[7];
var restoreStateIfNeeded$1 = _ReactDOM$__SECRET_IN$1[8];
var dispatchEvent$1 = _ReactDOM$__SECRET_IN$1[9];
var runEventsInBatch$1 = _ReactDOM$__SECRET_IN$1[10];
var flushPassiveEffects$1 = _ReactDOM$__SECRET_IN$1[11];
var IsThisRendererActing$1 = _ReactDOM$__SECRET_IN$1[12];
var batchedUpdates = ReactDOM.unstable_batchedUpdates;
var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; // this implementation should be exactly the same in
// ReactTestUtilsAct.js, ReactTestRendererAct.js, createReactNoop.js

var isSchedulerMocked = typeof Scheduler.unstable_flushAllWithoutAsserting === 'function';

var flushWork = Scheduler.unstable_flushAllWithoutAsserting || function () {
  var didFlushWork = false;

  while (flushPassiveEffects$1()) {
    didFlushWork = true;
  }

  return didFlushWork;
};

function flushWorkAndMicroTasks(onDone) {
  try {
    flushWork();
    enqueueTask$1(function () {
      if (flushWork()) {
github facebook / react / packages / react-reconciler / src / ReactFiberWorkLoop.js View on Github external
export function warnIfUnmockedScheduler(fiber: Fiber) {
  if (__DEV__) {
    if (
      didWarnAboutUnmockedScheduler === false &&
      Scheduler.unstable_flushAllWithoutAsserting === undefined
    ) {
      if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) {
        didWarnAboutUnmockedScheduler = true;
        console.error(
          'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' +
            'to guarantee consistent behaviour across tests and browsers. ' +
            'For example, with jest: \n' +
            "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" +
            'For more info, visit https://fb.me/react-mock-scheduler',
        );
      } else if (warnAboutUnmockedScheduler === true) {
        didWarnAboutUnmockedScheduler = true;
        console.error(
          'Starting from React v17, the "scheduler" module will need to be mocked ' +
            'to guarantee consistent behaviour across tests and browsers. ' +
            'For example, with jest: \n' +
github facebook / react / packages / react-reconciler / src / ReactFiberWorkLoop.js View on Github external
export function warnIfUnmockedScheduler(fiber: Fiber) {
  if (__DEV__) {
    if (
      didWarnAboutUnmockedScheduler === false &&
      Scheduler.unstable_flushAllWithoutAsserting === undefined
    ) {
      if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) {
        didWarnAboutUnmockedScheduler = true;
        warningWithoutStack(
          false,
          'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' +
            'to guarantee consistent behaviour across tests and browsers. ' +
            'For example, with jest: \n' +
            "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" +
            'For more info, visit https://fb.me/react-mock-scheduler',
        );
      } else if (warnAboutUnmockedScheduler === true) {
        didWarnAboutUnmockedScheduler = true;
        warningWithoutStack(
          false,
          'Starting from React v17, the "scheduler" module will need to be mocked ' +