programmatically redirect react router
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 { Route } from 'react-router-dom'
const Button = () => (
<Route render={({ history}) => (
<button
type='button'
onClick={() => { history.push('/new-location') }}
>
Click Me!
</button>
)} />
)import { useHistory } from "react-router-dom";
function HomeButton() {
const history = useHistory();
function handleClick() {
history.push("/home");
}
return (
<button type="button" onClick={handleClick}>
Go home
</button>
);
}
Also in JavaScript:
- mongoose virtual populate not working
- reload page javascript
- javascript urlsearchparams to object
- parameters types in javascript
- js string times
- hidden jquery
- jquery on form submit call function
- how to find id in array javascript
- js check if div have another div
- three.js create sphere
- how to convert a number to a string in javascript
- remove second last element from array javascript
- swiftyjson
- jquery add contenteditable="true"
- javascript key pressed enter
- javascript date get current date
- vue sidebar
- node js check type of variable
- No matching version found for swagger-jsdoc@^6.0.0.
- javascript cut string
- tays javascript answer test
- javascript get dictionary values
- select parent of elemt
- update one component from another component angular 9