react redirect on click
import React from 'react';
import { useHistory } from "react-router-dom";
function Home() {
const history = useHistory();
const handleRoute = () =>{
history.push("/about");
}
return (
<Button
onClick={handleRoute}>
About
</Button>
);
}
export default Home;import { useHistory } from 'react-router-dom';
function app() {
let history = useHistory();
const redirect = () => {
history.push('/your-path')
}
return (
<div>
<button onClick={redirect}>Redirect</button>
</div>
)
}
Also in JavaScript:
- in select option how to make one default in angular
- How to check if a member has a role discord.js
- how to set variable in discord.js
- javascript remove element from array
- cypress fixture
- how to send a message discord.js
- electron specify minimum size
- Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class
- simulate schrool event puppeter
- discord.js reply to message author
- syntax for srcset in react
- indexof javascript duplicate arrays
- angular for each
- useBootstrapPrefixhttp://localhost:8000/static/js/bundle.js:15261:75
- node console showing object object
- jquery scrollHeight
- how to stop user from clicking outside alert box js
- javascript break for loop
- stop a setinterval
- html shortcuts in jsx
- jquery check if screen size
- array sort
- mongodb delete duplicate documents
- how to delete object property of array javascript