如果路径是 /login,则只应呈现登录组件。它确实有效,但现在如果通过 Tabs 组件从 /posts/1 到 /posts/2 更新路径,则整个页面将重新呈现。
我实际上希望单独显示登录组件。其他一切都应该保持不变。我试过这样:
import React from "react";
import Tabs from "./components/Tabs";
import { Router } from "@reach/router";
import SignIn from "./components/SignIn";
import AppBar from "./components/AppBar";
export default function Screen() {
const Home = () => (
<React.Fragment>
<AppBar />
<Tabs />
</React.Fragment>
);
return (
<React.Fragment>
<Router>
<SignIn path="login" />
<Home path="/*" />
</Router>
</React.Fragment>
);
}