“haczyk użytkowe ()” Kod odpowiedzi

Użyj

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

Przykład użytkowania

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

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

równoważny użytkowania w React

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

haczyk użytkowe ()

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

check out the source link
DareDevil992

Odpowiedzi podobne do “haczyk użytkowe ()”

Pytania podobne do “haczyk użytkowe ()”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu