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