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