react router dom current path hook
import { useHistory } from "react-router-dom";
function HomeButton() {
let history = useHistory();
function handleClick() {
history.push("/home");
}
return (
<button type="button" onClick={handleClick}>
Go home
</button>
);
}
import { useLocation } from 'react-router-dom'
// Location is, for example: http://localhost:3000/users/new
// Care! MyComponent must be inside Router to work
const MyComponent = () => {
const location = useLocation()
// location.pathname is '/users/new'
return <span>Path is: {location.pathname}</span>
}
export default MyComponent
Also in JavaScript:
- javascript Error: Invalid web service call, missing value for parameter: 'documentId'.
- nuxt vuetify google fonts
- javascript get domain name from string
- how to use the map method in javascript
- javascript get a random number with 6 digits
- express signed cookies
- angular on back skip routes
- do i have to include jquery files at head of bootstrap
- javascript onclick
- get select option count using jquery
- jquery basic authenticated get user
- javascript multiplication table
- materal ui react range slider
- display none js
- javascript find prime number
- javascript math absolute
- forloop angular
- react native updating options with setoptions
- node.js discord dashboard
- append to top javascript
- get downloadable link to s3 bucket object js
- array sort by key javascript
- get value onChange from mat-select angular
- how to import dotenv in react