I need some help to accomplish routing in ReactJS. I describe my problem and hope you can help me..
I have famous index.js in this file and I call app.js from it
**index.js**
render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('app')
);
inside app.js I wrote some code for routing as below :
**App.js**
return (
<div>
{message &&
<div className={`alert ${type}`}>{message}</div>
}
<Router history={history}>
<div>
<PrivateRoute exact path="/" component={Main} />
<Route path="/login" component={SignIn} />
</div>
</Router>
</div>
);
this work correctly and after login I redirect to Main.js
and now my problem :
I`ve written some route in Main.js page that all other pages must inherit from that. I mean all other page must have the skeleton of Main.js
here is some code of Main.js
**Main.js**
<main className={classes.content}>
<Link to="/HomePage"> HomePage</Link>
<Link to="/Admin"> Admin </Link>
<Link to="/Menus"> Menu </Link>
<Link to="/Product"> Product </Link>
<div className={classes.appBarSpacer} />
<Switch>
<PrivateRoute path="/HomePage" component={HomePage} />
<PrivateRoute path="/Admin" component={Admin} />
<PrivateRoute path="/Menus" component={Menus} />
<PrivateRoute path="/Product" component={Product} />
</Switch>
</main>
unfortunately none of this routes works.. I`m extremely confused because all of things seems right