react get current route
/*In the 5.1 release of react-router there is a hook called useLocation,
which returns the current location object.
This might be useful any time you need to know the current URL.*/
import { useLocation } from 'react-router-dom';
const location = useLocation();
console.log(location.pathname);
import {withRouter} from 'react-router-dom';
const SomeComponent = withRouter(props => <MyComponent {...props}/>);
class MyComponent extends React.Component {
SomeMethod () {
const {pathname} = this.props.location;
}
}
Also in JavaScript:
- javascript question mark
- promise nodejs
- export default function react
- How to create HTML forms and attach JavaScript behaviors ALL TYPES
- angular loop through array
- strict equality
- how to pause useState counter value react hoooks
- add item to list javascript
- jquery post with promises
- Error:....... EPERM: operation not permitted, mkdi
- s3 list objects in folder node js
- javascript replace all occurrences of string
- iterate over json data javascript
- jquery if else on click
- find vowels in string javascript
- expo build apk
- function js
- length of an object in javascript
- user account in react
- pass argument to event listener javascript
- check date clash js
- javascript includes
- transformorigin gsap
- if string have any digits javascript