ログアウトした状態で PrivateRoute で指定した場所にアクセスするとURLそのままでコンテンツが切り替わるので
Closed this issue · 0 comments
dsk52 commented
以下でIndexをあてているのが原因。
const { user } = useContext(AuthContext);
const Component = user ? RouteComponent : Index;
return <Route {...options} component={Component} />
user の状態で、RouteとRedirectを切り替えるのが良さそうな気がするんだけど、反応ないのがつらい
<Redirect to='/' />
こういうのも反応がない。 withRouter() で export かけるのもやったけど変わらず
return (
<Route
{...options}
render={() =>
user ? (
<RouteComponent />
) : (
<Redirect to="/" />
)
}
/>
)