Ejemplo 1: redireccionar onclick reaccionar
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;
Ejemplo 2: reaccionar redireccionar al hacer clic
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>
)
}
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)