“usehistory react-router-dom” Respostas de código

usehistory react-router-dom

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

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

REACH ROUTER DOM CANTO CANTO DO CANTO

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 MyComponent
Mr Dom

Respostas semelhantes a “usehistory react-router-dom”

Perguntas semelhantes a “usehistory react-router-dom”

Procure respostas de código populares por idioma

Procurar outros idiomas de código