score:2

Accepted answer
import {withRouter} from 'react-router-dom'

const App = ({
  history,
}) => {
  const code = new URLSearchParams(
    new URL(history.pathname).search
  ).get('code')
  if(code) {
    useCode(code)
    history.replace('/')
  }
  return (
    <div>...</div>
  )
}

export default withRouter(App)

Related Query

More Query from same tag