function App() {
return (
<>
<CssBaseline />
<Router>
<Switch>
<Route path="/auth">
<Auth></Auth>
</Route>
<Container>
<Route path="/sign-in" component={SignIn} />
<Route path="/home" component={Home} />
<Route path="/load" component={Load} />
</Container>
<Route>
<Redirect to="/sign-in"></Redirect>
</Route>
</Switch>
</Router>
</>
);
}
<Container>
is a context provider.
export const Container = ({ children }: { children: JSX.Element[] }) => {
return <AuthContainer.Provider>
<DataContainer.Provider>
{children}
</DataContainer.Provider>
</AuthContainer.Provider>
}
when location is in /
, the <Redirect>
have no effect.
changing <Route>
to<Route path="/" exact>
have no effect in /
,either .
Please tell me the reason, thank you.
I move the <Container>
to the out of <Switch>
,thing go to be correct.but why?