react get params from url tsx code example
Example 1: get current url react router
import {withRouter} from 'react-router-dom';
const SomeComponent = withRouter(props => <MyComponent {...props}/>);
class MyComponent extends React.Component {
SomeMethod () {
const {pathname} = this.props.location;
}
}
Example 2: react get route params
const Child = ({ match }) => (
<div>
<h3>ID: {match.params.id}</h3>
</div>
)