src/act-compat.js
async function asyncActPolyfill(cb) {
  // istanbul-ignore-next
  if (
    !youHaveBeenWarned &&
    actSupported &&
    reactDomSixteenPointNineIsReleased
  ) {
    // if act is supported and async act isn't and they're trying to use async
    // act, then they need to upgrade from 16.8 to 16.9.
    // This is a seemless upgrade, so we'll add a warning
    console.error(
      `It looks like you're using a version of react-dom that supports the "act" function, but not an awaitable version of "act" which you will need. Please upgrade to at least react-dom@16.9.0 to remove this warning.`,
    )
    youHaveBeenWarned = true
  }
  await cb()
  // make all effects resolve after
  act(() => {})
}
async function asyncActPolyfill(cb) {
  // istanbul-ignore-next
  if (
    !youHaveBeenWarned &&
    actSupported &&
    reactDomSixteenPointNineIsReleased
  ) {
    // if act is supported and async act isn't and they're trying to use async
    // act, then they need to upgrade from 16.8 to 16.9.
    // This is a seemless upgrade, so we'll add a warning
    console.error(
      `It looks like you're using a version of react-dom that supports the "act" function, but not an awaitable version of "act" which you will need. Please upgrade to at least react-dom@16.9.0 to remove this warning.`,
    )
    youHaveBeenWarned = true
  }
  await cb()
  // make all effects resolve after
  act(() => {})
}
async function asyncActPolyfill ( cb ) { // istanbul-ignore-next if ( ! youHaveBeenWarned && actSupported && reactDomSixteenPointNineIsReleased ) { // if act is supported and async act isn't and they're trying to use async // act, then they need to upgrade from 16.8 to 16.9. // This is a seemless upgrade, so we'll add a warning console . error ( ` ` , ) youHaveBeenWarned = true } await cb ( ) // make all effects resolve after act ( ( ) => { } ) }
this will not avoid warnings that react-dom 16.8.0 logs for triggering state updates asynchronously, but at least we can tell people they need to upgrade to avoid the warnings.
this will not avoid warnings that react - dom 16 . 8 . 0 logs for triggering state updates asynchronously but at least we can tell people they need to upgrade to avoid the warnings .