In React, how to create 3 different menus in 3 different pages:
there is a Home page where you choose to be a customer or a seller, and depending on the page chosen (customer page or seller page) you have a new menu which will call up pages specific to the seller or customer.
function App({ Component, pageProps }) {
return (
<Provider store={store}>
<PersistGate persistor={persistor}>
<Head>
<title>Title</title>
</Head>
<Component {...pageProps} />
</PersistGate>
</Provider>
);
}
import Home from '../components/Home';
function Index() {
return <Home />;
}
export default Index;
2
Answers
you use useState like
and in menu links or buttons you can choose the elements that should display
.
.
.
and change the userState in it’s correct place like response from the api or something like that
You can use React Router to manage navigation between different pages
First you have to install
react-router-dom.
Second, Create a Home component that allows users to choose between being a customer or a seller.
And create separate components for the Customer and Seller Pages
Update the APP Component to Include React router
Now, when a user selects "Customer" or "Seller" on the home page, they will be directed to the corresponding pages with different menus based on their role.