I'm trying to implement private and public routes using hookrouter package in Reactjs.(The app is based on react-hooks.)The snippet of my code is as follows-
(我正在尝试使用Reactjs中的hookrouter包实现私有和公共路由(该应用程序基于react-hooks)。我的代码片段如下-)
in routes.js
(在routes.js中)
export const publicRoutes = {
"/": () => <Login />,
"/Signup": () => <Signup />,
}
export const privateRoutes = {
"/Dashboard": () => <Dashboard />,
}
in App.js
(在App.js中)
import { useRoutes, navigate} from "hookrouter";
const publicRoutesApp = useRoutes(publicRoutes);
const privateRoutesApp = useRoutes(privateRoutes);
{!isLoggedIn() ? publicRoutesApp : privateRoutesApp}
ask by ravi kumar translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…