How to use js route redirection in react-router4.2?

1. There is a button on the page. Click this button to jump to the page

:withRouter

=
import React from "react"
import PropTypes from" prop-types"
import {withRouter} from "react-router"

class ShowTheLocation extends React.Component {
static propTypes = {

match: PropTypes.object.isRequired,
location: PropTypes.object.isRequired,
history: PropTypes.object.isRequired

}

render () {

const { match, location, history } = this.props

return (
  <div>You are now at {location.pathname}</div>
)

}
}

const ShowTheLocationWithRouter = withRouter (ShowTheLocation)

=
how to use this code in practical application?
withRouter is a high-level component? Return a ShowTheLocationWithRouter function? So how do you use jump in this function?

const {match, location, history} = this.props / / what does this line mean?

< H1 > use history.push ("/ xxx") like this? < / H1 >

now there is a button component how to add events to this component for routing redirection

Mar.15,2021

after you get the history, you can jump with code. ReactTraining/history: Manage session history with JavaScript this is the history repository. Check this document



import history from 'history'
history.push(path)
Menu