“usenavigate” Respostas de código

usenavigate

In react-router-dom version 6 
useHistory() is replaced by useNavigate() ;

import {useNavigate} from 'react-router-dom';
const navigate = useNavigate();
navigate('/home')
Joyous Jackal

usenavigate

// React Router v6
import { useNavigate } from 'react-router-dom';

export function GoHome() {
  let navigate = useNavigate();
  const handleClick = e => {
    e.preventDefault();
    navigate('/home');
  }
  return <button onClick={handleClick}>Go to Home</button>
}
Coffee Addict

Respostas semelhantes a “usenavigate”

Procure respostas de código populares por idioma

Procurar outros idiomas de código