Got an Unhandeled Error at run time while checking state of user

For me the problem was related with <AmplifySignOut /> component, it seems that component does not exists in current library version, so what I did was just get the signOut callback from props and using a custom button to call this action.

// pages/profile.js
import { useState, useEffect } from 'react'
import { Auth } from 'aws-amplify'
import { withAuthenticator,   } from '@aws-amplify/ui-react'

function Profile({signOut}) { // <-- !!!         Here
  const [user, setUser] = useState(null)
  useEffect(() => {
    // Access the user session on the client
    Auth.currentAuthenticatedUser()
      .then(user => {
        console.log("User: ", user)
        setUser(user)
      })
      .catch(err => setUser(null))
  }, [])
  return (
    <div>
      { user &&  <div> 
          <h1>Welcome, {user.username}</h1>
          <button onClick={signOut}>Sign out</button>// <-- Here
          </div> }
    </div>
  )
}

export default withAuthenticator(Profile)

Please check the most updated version of documentation because implmentation migth have changed over time Amplify Docs