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