I believe you can just add a new route to App.js. For example:
function App() {
return (
<Router>
<Navbar />
<div className="App">
<Switch>
<Route
exact
path="/"
render={() => (
<React.Fragment>
<AddPostForm/>
<PostsList/>
</React.Fragment>
)}
/>
<Route exact path="/posts/:postId" component={SinglePostPage} />
<Route exact path="/editPost/:id" component={EditPostForm} />
<Redirect to="/" />
</Switch>
</div>
</Router>
)
}
export default App;
and then in SinglePostPage your path for the link is slightly wrong, it should be:
<Link to={`/editPost/${post.id}`}>...</Link>
You were missing first '/'
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…