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 @@ -21,20 +21,22 @@ try {
2121 // we can't use regular timers because they may still be faked
2222 // so we try MessageChannel+postMessage instead
2323 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 ) {
2530 didWarnAboutMessageChannel = true
31+
2632 // eslint-disable-next-line no-console
2733 console . error (
28- typeof MessageChannel !== 'undefined' ,
2934 'This browser does not have a MessageChannel implementation, ' +
3035 'so enqueuing tasks via await act(async () => ...) will fail. ' +
3136 'Please file an issue at https://github.com/facebook/react/issues ' +
3237 'if you encounter this warning.' ,
3338 )
3439 }
35- const channel = new MessageChannel ( )
36- channel . port1 . onmessage = callback
37- channel . port2 . postMessage ( undefined )
3840 }
3941}
4042
You can’t perform that action at this time.
0 commit comments