Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

equivalent of useHistory in react

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

usehistory example

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

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

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')
Comment

useHistory() hook

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

check out the source link
Comment

PREVIOUS NEXT
Code Example
Javascript :: js add string to beginning of string 
Javascript :: javascript set input field value 
Javascript :: reset date input javascript 
Javascript :: javascript truncate with ellipsis 
Javascript :: javascript get last character of string 
Javascript :: element without a particular class jquery 
Javascript :: prevent reload javascript 
Javascript :: disable input angular 
Javascript :: check given path is valid or not in nodejs 
Javascript :: count 1 to 5 javascript 
Javascript :: install the same version of package in the package.json 
Javascript :: how to get first and last name from email js regex 
Javascript :: javascript emit beep 
Javascript :: discord login with token 
Javascript :: javascript download json 
Javascript :: how to find text in jquery with find function 
Javascript :: for key value in object javascript 
Javascript :: stop settimeout 
Javascript :: javascript delete cookie 
Javascript :: redirect window 
Javascript :: how will it look when there is a container inside a a row bootstrap 
Javascript :: javascript keywords 
Javascript :: js round to nearest thousand 
Javascript :: how can we redirect to third party page in angular 
Javascript :: remove bearer from token in node js 
Javascript :: nodejs merge 2 objects 
Javascript :: js stop scrolling event 
Javascript :: jquery datepicker change date format 
Javascript :: javascript set attribute href 
Javascript :: jquery on 2 events 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =