“UseHistory () Haken” Code-Antworten

Gebrauchsgeschichte

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

nuwhistory -Beispiel

import { useHistory } from 'react-router-dom';

function Home() {
  const history = useHistory();
  return <button onClick={() => history.push('/profile')}>Profile</button>;
}
Repulsive Rook

Äquivalent der Verwendung in React

import { useHistory } from "react-router-dom"; // DEPRECATED
// It is now
import { useNavigate } from "react-router-dom"; // As at March 3, 2022
Code Rabbi

UseHistory () Haken

// useHistory() has been changed in v6, so instead use useNavigate()

check out the source link
DareDevil992

Ähnliche Antworten wie “UseHistory () Haken”

Fragen ähnlich wie “UseHistory () Haken”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen