GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add `supportsMicrotasks` to the host config (#20809) · react/react@1a74726

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • react-art/src
      • ReactARTHostConfig.js
    • react-dom/src/client
      • ReactDOMHostConfig.js
    • react-native-renderer/src
      • ReactFabricHostConfig.js
      • ReactNativeHostConfig.js
    • react-noop-renderer/src
      • createReactNoop.js
    • react-reconciler
      • README.md
      • src
        • ReactFiberHostConfigWithNoMicrotasks.js
        • ReactFiberWorkLoop.new.js
        • ReactFiberWorkLoop.old.js
        • forks
          • ReactFiberHostConfig.custom.js
    • react-test-renderer/src
      • ReactTestHostConfig.js
  • scripts/error-codes
    • codes.json
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-art/src/ReactARTHostConfig.js‎

Copy file name to clipboardExpand all lines: packages/react-art/src/ReactARTHostConfig.js
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ export * from 'react-reconciler/src/ReactFiberHostConfigWithNoPersistence';
249249
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoHydration';
250250
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoScopes';
251251
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoTestSelectors';
252+
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoMicrotasks';
252253

253254
export function appendInitialChild(parentInstance, child) {
254255
if (typeof child === 'string') {
@@ -338,9 +339,6 @@ export function getChildHostContext() {
338339
export const scheduleTimeout = setTimeout;
339340
export const cancelTimeout = clearTimeout;
340341
export const noTimeout = -1;
341-
export function scheduleMicrotask(callback: Function) {
342-
invariant(false, 'Not implemented.');
343-
}
344342

345343
export function shouldSetTextContent(type, props) {
346344
return (
Collapse file

‎packages/react-dom/src/client/ReactDOMHostConfig.js‎

Copy file name to clipboardExpand all lines: packages/react-dom/src/client/ReactDOMHostConfig.js
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import {
6767
enableCreateEventHandleAPI,
6868
enableScopeAPI,
6969
enableNewReconciler,
70+
enableDiscreteEventMicroTasks,
7071
} from 'shared/ReactFeatureFlags';
7172
import {HostComponent, HostText} from 'react-reconciler/src/ReactWorkTags';
7273
import {listenToAllSupportedEvents} from '../events/DOMPluginEventSystem';
@@ -399,6 +400,11 @@ export const scheduleTimeout: any =
399400
export const cancelTimeout: any =
400401
typeof clearTimeout === 'function' ? clearTimeout : (undefined: any);
401402
export const noTimeout = -1;
403+
404+
// -------------------
405+
// Microtasks
406+
// -------------------
407+
export const supportsMicrotasks = enableDiscreteEventMicroTasks;
402408
export const scheduleMicrotask: any =
403409
typeof queueMicrotask === 'function'
404410
? queueMicrotask
Collapse file

‎packages/react-native-renderer/src/ReactFabricHostConfig.js‎

Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactFabricHostConfig.js
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export * from 'react-reconciler/src/ReactFiberHostConfigWithNoMutation';
193193
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoHydration';
194194
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoScopes';
195195
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoTestSelectors';
196+
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoMicrotasks';
196197

197198
export function appendInitialChild(
198199
parentInstance: Instance,
@@ -360,9 +361,6 @@ export const warnsIfNotActing = false;
360361
export const scheduleTimeout = setTimeout;
361362
export const cancelTimeout = clearTimeout;
362363
export const noTimeout = -1;
363-
export function scheduleMicrotask(callback: Function) {
364-
invariant(false, 'Not implemented.');
365-
}
366364

367365
// -------------------
368366
// Persistence
Collapse file

‎packages/react-native-renderer/src/ReactNativeHostConfig.js‎

Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactNativeHostConfig.js
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export * from 'react-reconciler/src/ReactFiberHostConfigWithNoPersistence';
9797
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoHydration';
9898
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoScopes';
9999
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoTestSelectors';
100+
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoMicrotasks';
100101

101102
export function appendInitialChild(
102103
parentInstance: Instance,
@@ -255,9 +256,6 @@ export const warnsIfNotActing = true;
255256
export const scheduleTimeout = setTimeout;
256257
export const cancelTimeout = clearTimeout;
257258
export const noTimeout = -1;
258-
export function scheduleMicrotask(callback: Function) {
259-
invariant(false, 'Not implemented.');
260-
}
261259

262260
export function shouldSetTextContent(type: string, props: Props): boolean {
263261
// TODO (bvaughn) Revisit this decision.
Collapse file

‎packages/react-noop-renderer/src/createReactNoop.js‎

Copy file name to clipboardExpand all lines: packages/react-noop-renderer/src/createReactNoop.js
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ import {
2727
LegacyRoot,
2828
} from 'react-reconciler/src/ReactRootTags';
2929

30-
import {enableNativeEventPriorityInference} from 'shared/ReactFeatureFlags';
30+
import {
31+
enableNativeEventPriorityInference,
32+
enableDiscreteEventMicroTasks,
33+
} from 'shared/ReactFeatureFlags';
3134
import ReactSharedInternals from 'shared/ReactSharedInternals';
3235
import enqueueTask from 'shared/enqueueTask';
3336
const {IsSomeRendererActing} = ReactSharedInternals;
@@ -372,6 +375,8 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
372375
scheduleTimeout: setTimeout,
373376
cancelTimeout: clearTimeout,
374377
noTimeout: -1,
378+
379+
supportsMicrotasks: enableDiscreteEventMicroTasks,
375380
scheduleMicrotask:
376381
typeof queueMicrotask === 'function'
377382
? queueMicrotask
Collapse file

‎packages/react-reconciler/README.md‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/README.md
+4-1Lines changed: 4 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,12 @@ You can proxy this to `clearTimeout` or its equivalent in your environment.
203203

204204
This is a property (not a function) that should be set to something that can never be a valid timeout ID. For example, you can set it to `-1`.
205205

206+
#### `supportsMicrotask`
207+
208+
Set this to true to indicate that your renderer supports `scheduleMicrotask`. We use microtasks as part of our discrete event implementation in React DOM. If you're not sure if your renderer should support this, you probably should. The option to not implement `scheduleMicrotask` exists so that platforms with more control over user events, like React Native, can choose to use a different mechanism.
206209
#### `scheduleMicrotask(fn)`
207210

208-
You can proxy this to `queueMicrotask` or its equivalent in your environment.
211+
Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.
209212

210213
#### `isPrimaryRenderer`
211214

Collapse file

‎packages/react-reconciler/src/ReactFiberHostConfigWithNoMicrotasks.js‎

Copy file name to clipboard
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
import invariant from 'shared/invariant';
11+
12+
// Renderers that don't support microtasks
13+
// can re-export everything from this module.
14+
15+
function shim(...args: any) {
16+
invariant(
17+
false,
18+
'The current renderer does not support microtasks. ' +
19+
'This error is likely caused by a bug in React. ' +
20+
'Please file an issue.',
21+
);
22+
}
23+
24+
// Test selectors (when unsupported)
25+
export const supportsMicrotasks = false;
26+
export const scheduleMicrotask = shim;
Collapse file

‎packages/react-reconciler/src/ReactFiberWorkLoop.new.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ import {
9393
warnsIfNotActing,
9494
afterActiveInstanceBlur,
9595
clearContainer,
96-
scheduleMicrotask,
9796
getCurrentEventPriority,
97+
supportsMicrotasks,
98+
scheduleMicrotask,
9899
} from './ReactFiberHostConfig';
99100

100101
import {
@@ -219,7 +220,6 @@ import {
219220
syncNestedUpdateFlag,
220221
} from './ReactProfilerTimer.new';
221222

222-
import {enableDiscreteEventMicroTasks} from 'shared/ReactFeatureFlags';
223223
// DEV stuff
224224
import getComponentName from 'shared/getComponentName';
225225
import ReactStrictModeWarnings from './ReactStrictModeWarnings.new';
@@ -756,7 +756,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
756756
performSyncWorkOnRoot.bind(null, root),
757757
);
758758
} else if (
759-
enableDiscreteEventMicroTasks &&
759+
supportsMicrotasks &&
760760
newCallbackPriority === InputDiscreteLanePriority
761761
) {
762762
scheduleMicrotask(performSyncWorkOnRoot.bind(null, root));
Collapse file

‎packages/react-reconciler/src/ReactFiberWorkLoop.old.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ import {
9393
warnsIfNotActing,
9494
afterActiveInstanceBlur,
9595
clearContainer,
96-
scheduleMicrotask,
9796
getCurrentEventPriority,
97+
supportsMicrotasks,
98+
scheduleMicrotask,
9899
} from './ReactFiberHostConfig';
99100

100101
import {
@@ -219,7 +220,6 @@ import {
219220
syncNestedUpdateFlag,
220221
} from './ReactProfilerTimer.old';
221222

222-
import {enableDiscreteEventMicroTasks} from 'shared/ReactFeatureFlags';
223223
// DEV stuff
224224
import getComponentName from 'shared/getComponentName';
225225
import ReactStrictModeWarnings from './ReactStrictModeWarnings.old';
@@ -756,7 +756,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
756756
performSyncWorkOnRoot.bind(null, root),
757757
);
758758
} else if (
759-
enableDiscreteEventMicroTasks &&
759+
supportsMicrotasks &&
760760
newCallbackPriority === InputDiscreteLanePriority
761761
) {
762762
scheduleMicrotask(performSyncWorkOnRoot.bind(null, root));
Collapse file

‎packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const shouldSetTextContent = $$$hostConfig.shouldSetTextContent;
5454
export const createTextInstance = $$$hostConfig.createTextInstance;
5555
export const scheduleTimeout = $$$hostConfig.scheduleTimeout;
5656
export const cancelTimeout = $$$hostConfig.cancelTimeout;
57-
export const scheduleMicrotask = $$$hostConfig.scheduleMicrotask;
5857
export const noTimeout = $$$hostConfig.noTimeout;
5958
export const now = $$$hostConfig.now;
6059
export const isPrimaryRenderer = $$$hostConfig.isPrimaryRenderer;
@@ -75,6 +74,13 @@ export const prepareScopeUpdate = $$$hostConfig.preparePortalMount;
7574
export const getInstanceFromScope = $$$hostConfig.getInstanceFromScope;
7675
export const getCurrentEventPriority = $$$hostConfig.getCurrentEventPriority;
7776

77+
// -------------------
78+
// Microtasks
79+
// (optional)
80+
// -------------------
81+
export const supportsMicrotasks = $$$hostConfig.supportsMicrotasks;
82+
export const scheduleMicrotask = $$$hostConfig.scheduleMicrotask;
83+
7884
// -------------------
7985
// Test selectors
8086
// (optional)

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.