Reputation: 82
When I try reload subpage app redirect me to main page.
When I type in browser subpage (example: /about
) app redirect me to main page.
It's my router component in App.js.
P.S I use arrow functions in React.
<Router>
<Header />
<Container history={props.history}>
<Route exact path="/" component={SelectLogin} />
<Route path="/selectlogin" component={SelectLogin} />
<Route path="/about" component={About} />
<Route path="/register" component={RegisterPanel} />
<Route path="/addcomment" component={AddComment} />
<Route path="/findposts" component={FindPosts} />
<Route path="/lostposts" component={LostPosts} />
<Route path="/posts" component={Posts} />
<Route path="/lostpost" component={LostPost} />
<Route path="/findrequest" component={FindRequest} />
<Route path="/lostrequest" component={LostRequest} />
<Route path="/requestsummary" component={Summary} />
<Route path="/logincode" component={LoginCodePanel} />
<Route path="/logindata" component={LoginDataPanel} />
<Route path="/adminpanel" component={AdminPanel} />
<Route path="/editprofile" component={EditProfile} />
<Route path="/userpanel" component={UserPanel} />
<Route path="/userposts/:id" component={UserPosts} />
<Route path="/editpost" component={EditPost} />
</Container>
</Router>
Upvotes: 0
Views: 159
Reputation: 15166
I believe you missed <Switch />
component in the middle.
Try the following:
<Router>
<Switch>
<Header />
<Container history={props.history}>
<Route exact path="/" component={SelectLogin} />
{ /* all the other routes */ }
<Route path="/editpost" component={EditPost} />
</Container>
</Switch>
</Router>
See a basic routing example here.
I hope this helps!
Upvotes: 1