useHistory react-router-dom
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 MyComponentIn react-router-dom version 6
useHistory() is replaced by useNavigate() ;
import {useNavigate} from 'react-router-dom';
const navigate = useNavigate();
navigate('/home')
Also in JavaScript:
- javascript how to check if array is empty
- refresh javascript using require
- node js how to basic auth to specific urk
- unix time to date javascript
- node js mongoose text index
- makes number negative javascript
- make object readonly javascript
- javascript change page title
- create json model online
- emit resize event in angular
- node updaten
- javascript folder exists
- array javascript
- notification bell icon bootstrap react
- assign role on reaction by id discord.js
- js array of strings mongoose
- scoll a div to bottom in angular
- vue js cdn
- json search javascript
- how to refrence image in dart angular
- javascript javascript javascript javascript javascript
- group by in javascript
- use bootstrap in react
- javascript modify href attr