score:3

Accepted answer
<Route path='/' component={Home} onEnter={requireAuth}>

function requireAuth(nextState, replace) {
  if (!role) {
    replace({
      pathname: '/login',
      state: { nextPathname: nextState.location.pathname }
    })
  }
}

score:2

<Route path="/" component={role===undefined ? Login : Home} />

Related Query

More Query from same tag