Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react router how to go back

// To get back to previous url adress:
import { useNavigate } from "react-router-dom";

const MyButton = () => {
  const navigate = useNavigate();

  return (
    <button
      onClick={() => {
        navigate(-1);
      }}
    >
      Click me to go back!
    </button>
  );
};

export default MyButton
Comment

go back in react router dom

// If you have the props from react router
history.goBack()
Comment

react history go back

const history = useHistory()

const goBack = () => {
  history.goBack()
}

return (
  <button type="button" onClick={goBack}>
    Go back
  </button>
);
Comment

react router go back

// Step 1:
import { useNavigate } from "react-router-dom";
// Step 2:
const navigate = useNavigate();
// step 3:
<button onClick={() => navigate(-1)}> Back </button>
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript select option based on text 
Javascript :: material ui textfield with chips 
Javascript :: refresh ajax jquery 
Javascript :: css react 
Javascript :: range of numbers in javascript 
Javascript :: jest mock method by name 
Javascript :: sort() object values javascript 
Javascript :: react-slick 
Javascript :: p5.js how to display a text from string 
Javascript :: sanitize html in javascript 
Javascript :: mongodb date format dd/mm/yyyy 
Javascript :: points in three js 
Javascript :: if js 
Javascript :: get text in protractor 
Javascript :: p5.js typescript 
Javascript :: node cron npm how to use 
Javascript :: angular infinite scroll 
Javascript :: find items in array not in another array javascript 
Javascript :: reset value object js 
Javascript :: node js split 
Javascript :: multi-dimensional array js 
Javascript :: js dictionary 
Javascript :: javascript good practice 
Javascript :: get % of number javascript 
Javascript :: javascript input value change 
Javascript :: vue google map api for user marker location 
Javascript :: animate change of class angular 
Javascript :: how to make an event listener only work once 
Javascript :: vue js convert string to html 
Javascript :: js check string is date 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =