File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -22,20 +22,22 @@ try {
22
22
// we can't use regular timers because they may still be faked
23
23
// so we try MessageChannel+postMessage instead
24
24
enqueueTask = ( callback ) => {
25
- if ( didWarnAboutMessageChannel === false ) {
25
+ const supportsMessageChannel = typeof MessageChannel === 'function'
26
+ if ( supportsMessageChannel ) {
27
+ const channel = new MessageChannel ( )
28
+ channel . port1 . onmessage = callback
29
+ channel . port2 . postMessage ( undefined )
30
+ } else if ( didWarnAboutMessageChannel === false ) {
26
31
didWarnAboutMessageChannel = true
32
+
27
33
// eslint-disable-next-line no-console
28
34
console . error (
29
- typeof MessageChannel !== 'undefined' ,
30
35
'This browser does not have a MessageChannel implementation, ' +
31
36
'so enqueuing tasks via await act(async () => ...) will fail. ' +
32
37
'Please file an issue at https://github.com/facebook/react/issues ' +
33
38
'if you encounter this warning.'
34
39
)
35
40
}
36
- const channel = new MessageChannel ( )
37
- channel . port1 . onmessage = callback
38
- channel . port2 . postMessage ( undefined )
39
41
}
40
42
}
41
43
You can’t perform that action at this time.
0 commit comments