get parameter from url react router 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: get query params react
new URLSearchParams(this.props.location.search).get("your_query_param_key")
Example 3: get data from url using react
this.props.match.params.id