need generic custom back button code in react js for the web application
For further actions, you may consider blocking this person and/or reporting abuse
need generic custom back button code in react js for the web application
For further actions, you may consider blocking this person and/or reporting abuse
Ezekiel -
SEBASTIAN AIRTON COTRINA CACERES -
Nik Tomazic -
Edgaras -
Top comments (3)
Could you please be more specific?
To help you, the following information would be necessarry:
What do you expect from a "generic custom" back button?
Most of the time it is sufficient to route back (depending on answers to the questions above) in the onClick event.
thanks Robin for instant reply,
i am using React-Router.
and want to go back via history.
have to place one custom button in header component and whenever i will go on some page have to come back on render page. just like any browser back arrow works.
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
withRouter
to be able to get thehistory
object in via the properties (destructuringhistory
andlocation
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()
.