I trying to handle the path when I click <Link/>
and I need using e.preventDefault();
for prevent animations inside the router so this is my code,basically I can not capture the location path for change the history target:
import React from 'react';
import { Link } from "react-router-dom";
export default class NavTransitions extends React.Component {
constructor(props) {
super(props);
this.changeRoutePath=this.changeRoutePath.bind(this);
}
changeRoutePath(e){
e.preventDefault();
this.props.history.push(this.match.path);
console.log('this.match.path '+this.match.path);
console.log('changeRoutePath');
}
render(){
return(
<div>
<Link to="/item"
onClick={this.changeRoutePath}>Prevent </Link>
</div>
);
}
}
The error says this.math is undefined