With react-router
I can use the Link
element to create links which are natively handled by react router.
I see internally it calls t
Maybe not the best solution but it gets the job done:
import { Link } from 'react-router-dom';
// create functional component Post
export default Post = () => (
);
Basically, a logic tied to one action (in this case a post deletion) will end up calling a trigger for redirect. This is not ideal because you will add a DOM node 'trigger' to your markup just so you can conveniently call it when needed. Also, you will directly interact with the DOM, which in a React component may not be desired.
Still, this type of redirect is not required that often. So one or two extra, hidden links in your component markup would not hurt that much, especially if you give them meaningful names.