GeezerVison is showing github.com — Add queue microtask to host configs (#20668) · react/react@aa736a0
File tree
Expand file treeCollapse file tree
Open diff view settings
react-native-renderer/src react-reconciler/src/forks
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/react-art/src/ReactARTHostConfig.js +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -330,6 +330,9 @@ export function getChildHostContext() { |
330 | 330 | export const scheduleTimeout = setTimeout; |
331 | 331 | export const cancelTimeout = clearTimeout; |
332 | 332 | export const noTimeout = -1; |
| 333 | +export function queueMicrotask(callback: Function) { |
| 334 | + invariant(false, 'Not implemented.'); |
| 335 | +} |
333 | 336 |
|
334 | 337 | export function shouldSetTextContent(type, props) { |
335 | 338 | return ( |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/react-dom/src/client/ReactDOMHostConfig.js +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -384,6 +384,21 @@ export const scheduleTimeout: any = |
384 | 384 | export const cancelTimeout: any = |
385 | 385 | typeof clearTimeout === 'function' ? clearTimeout : (undefined: any); |
386 | 386 | export const noTimeout = -1; |
| 387 | +export const queueMicrotask: any = |
| 388 | + typeof global.queueMicrotask === 'function' |
| 389 | + ? global.queueMicrotask |
| 390 | + : typeof Promise !== 'undefined' |
| 391 | + ? callback => |
| 392 | + Promise.resolve(null) |
| 393 | + .then(callback) |
| 394 | + .catch(handleErrorInNextTick) |
| 395 | + : scheduleTimeout; |
| 396 | + |
| 397 | +function handleErrorInNextTick(error) { |
| 398 | + setTimeout(() => { |
| 399 | + throw error; |
| 400 | + }); |
| 401 | +} |
387 | 402 |
|
388 | 403 | // ------------------- |
389 | 404 | // Mutation |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactFabricHostConfig.js +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -348,6 +348,9 @@ export const warnsIfNotActing = false; |
348 | 348 | export const scheduleTimeout = setTimeout; |
349 | 349 | export const cancelTimeout = clearTimeout; |
350 | 350 | export const noTimeout = -1; |
| 351 | +export function queueMicrotask(callback: Function) { |
| 352 | + invariant(false, 'Not implemented.'); |
| 353 | +} |
351 | 354 |
|
352 | 355 | // ------------------- |
353 | 356 | // Persistence |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactNativeHostConfig.js +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -247,6 +247,9 @@ export const warnsIfNotActing = true; |
247 | 247 | export const scheduleTimeout = setTimeout; |
248 | 248 | export const cancelTimeout = clearTimeout; |
249 | 249 | export const noTimeout = -1; |
| 250 | +export function queueMicrotask(callback: Function) { |
| 251 | + invariant(false, 'Not implemented.'); |
| 252 | +} |
250 | 253 |
|
251 | 254 | export function shouldSetTextContent(type: string, props: Props): boolean { |
252 | 255 | // TODO (bvaughn) Revisit this decision. |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/react-noop-renderer/src/createReactNoop.js +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -371,6 +371,19 @@ function createReactNoop(reconciler: Function, useMutation: boolean) { |
371 | 371 | scheduleTimeout: setTimeout, |
372 | 372 | cancelTimeout: clearTimeout, |
373 | 373 | noTimeout: -1, |
| 374 | + queueMicrotask: |
| 375 | + typeof queueMicrotask === 'function' |
| 376 | + ? queueMicrotask |
| 377 | + : typeof Promise !== 'undefined' |
| 378 | + ? callback => |
| 379 | + Promise.resolve(null) |
| 380 | + .then(callback) |
| 381 | + .catch(error => { |
| 382 | + setTimeout(() => { |
| 383 | + throw error; |
| 384 | + }); |
| 385 | + }) |
| 386 | + : setTimeout, |
374 | 387 |
|
375 | 388 | prepareForCommit(): null | Object { |
376 | 389 | return null; |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -54,6 +54,7 @@ export const shouldSetTextContent = $$$hostConfig.shouldSetTextContent; |
54 | 54 | export const createTextInstance = $$$hostConfig.createTextInstance; |
55 | 55 | export const scheduleTimeout = $$$hostConfig.scheduleTimeout; |
56 | 56 | export const cancelTimeout = $$$hostConfig.cancelTimeout; |
| 57 | +export const queueMicrotask = $$$hostConfig.queueMicrotask; |
57 | 58 | export const noTimeout = $$$hostConfig.noTimeout; |
58 | 59 | export const now = $$$hostConfig.now; |
59 | 60 | export const isPrimaryRenderer = $$$hostConfig.isPrimaryRenderer; |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/react-test-renderer/src/ReactTestHostConfig.js +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -220,6 +220,21 @@ export const warnsIfNotActing = true; |
220 | 220 |
|
221 | 221 | export const scheduleTimeout = setTimeout; |
222 | 222 | export const cancelTimeout = clearTimeout; |
| 223 | +export const queueMicrotask = |
| 224 | + typeof global.queueMicrotask === 'function' |
| 225 | + ? global.queueMicrotask |
| 226 | + : typeof Promise !== 'undefined' |
| 227 | + ? (callback: Function) => |
| 228 | + Promise.resolve(null) |
| 229 | + .then(callback) |
| 230 | + .catch(handleErrorInNextTick) |
| 231 | + : scheduleTimeout; |
| 232 | + |
| 233 | +function handleErrorInNextTick(error) { |
| 234 | + setTimeout(() => { |
| 235 | + throw error; |
| 236 | + }); |
| 237 | +} |
223 | 238 | export const noTimeout = -1; |
224 | 239 |
|
225 | 240 | // ------------------- |
|