Started coding at the age of 13, now a professional software engineer and Scrum Master, creating and maintaining enterprise solutions. Eat - Sleep - Code - Lift - Repeat 💪🏾
First, use the HOC withRouter to be able to get the history object in via the properties (destructuring history and location in this example).
Then call .push() with the path you want to navigate to as parameter.
I don't recommend the second way, but here is another one: history.goBack().
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You can use the React Training documentation as a good starting point.
Normally you would to something like this to navigate via anchors:
But as you want to route via code, you would want to do something like this:
First, use the HOC
withRouterto be able to get thehistoryobject in via the properties (destructuringhistoryandlocationin this example).Then call
.push()with the path you want to navigate to as parameter.I don't recommend the second way, but here is another one:
history.goBack().