我在一家React堆工作。
我想在管理页面中隐藏我的导航栏组件。SO中有很多答案,但没有一个对我有效。请指导我如何执行此操作
- 我试过那个插座,但没有得到我的解决方案,也试过那个解决方案,但它在新的react版本中不工作 *
应用程序js
import './App.css';
import Header from './Views/Header';
import "../node_modules/bootstrap/dist/css/bootstrap.min.css";
import "../node_modules/bootstrap/dist/js/bootstrap.bundle.min.js";
import { Routes, Route } from 'react-router-dom';
import Home from './Views/Home';
import Contact from './Views/Contact';
import About from './Views/About';
import Footer from './Views/Footer';
import Login from './Views/Login';
import Signup from './components/Signup';
import UserDashboard from './Views/UserDashboard';
import AllData from './Views/AllData';
import AdminHome from './Admin/AdminHome';
import AdminLogin from './Admin/AdminLogin';
import Error from './Views/Error';
import Blog from './components/Blog';
import Logout from './components/Logout';
import { createContext, useReducer } from 'react';
import { reducer, initialState } from "../src/reducer/UseReducer"
import AboutUser from './components/AboutUser';
import UpdateUser from './components/UpdateUser';
import 'react-toastify/dist/ReactToastify.css';
import { ToastContainer } from 'react-toastify'
export const userContext = createContext()
function App() {
<ToastContainer />
const [state, dispatch] = useReducer(reducer, initialState)
return (
<>
<userContext.Provider value={{ state, dispatch }}>
<Header />
<Routes>
<Route exact path="/(login)" element={<Login />} />
<Route path='/' element={<Home />} />
<Route path='/about' element={<About />} />
<Route path='/contact' element={<Contact />} />
<Route path='/login' element={<Login />} />
<Route path='/signup' element={<Signup />} />
<Route path='/dashboard' element={<UserDashboard />} />
<Route path='/alldata' element={<AllData />} />
<Route path="*" element={<Error />} />
<Route path='/adminlogin' element={<AdminLogin />} />
<Route path='/admin' element={<AdminHome />} />
<Route path='/blog' element={<Blog />} />
<Route path='/logout' element={<Logout />} />
<Route path='/AboutUser' element={<AboutUser />} />
<Route path='/updateuser' element={<UpdateUser />} />
</Routes>
<Footer />
</userContext.Provider>
</>
);
}
export default App;
1条答案
按热度按时间brgchamk1#
请用支票付款