Simple question.
When I'm in a for instance /dashboard
router and I click on <Link to="/users/:userID" >
router and try to go back to /dashboard
it works wine , but when from /users/:userID
router I navigate to another /users/:userID
router and try to go back I need to click the back button twice , any idea why?
e.g.
/dashboard -> /users/1 and back ( 1 click needed )
/dashboard -> /users/1 - > /users/2 and back to /users/1 ( 2 clicks needed )
Here is my Route in App.js
<Route path='/users/:userId' render={()=><User/>} />
Here is my User.jsx render()
render() {
let movie = this.props.thisUserIdData;
const { match } = this.props;
console.log(match);
return (
<div> .... </div>
)
}
and the componentDidMount()
componentDidMount() {
this.loadData(this.props.match.params.userId);
//using redux and axios to get data
}
来源:https://stackoverflow.com/questions/48008290/react-router-with-params-navigatin-back-needs-double-click