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 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 :: how to get iso date with moment 
Javascript :: Iterating through an Object 
Javascript :: how to upgrade to react 18 
Javascript :: javascript group by property array of objects 
Javascript :: regex to extract valid http or https 
Javascript :: jquery count elements 
Javascript :: npm ERR! peer dep missing: @babel/core@^7.13.0, required by @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.14.5 
Javascript :: index export in nodejs 
Javascript :: remove unused dependencies in React Ask Question 
Javascript :: js get number from string 
Javascript :: document.ready shorthand 
Javascript :: how to see if a web site is useing react 
Javascript :: add element to body javascript 
Javascript :: react link underline 
Javascript :: string to number js 
Javascript :: Ajax Form All Data Send 
Javascript :: jquery only on mobile 
Javascript :: jquery get today date 
Javascript :: error: listen eaddrinuse: address already in use 0.0.0.0:5555 
Javascript :: discord js give role to all member 
Javascript :: Laravel csrf token mismatch for ajax POST Request 
Javascript :: jquery serialize form data and submit 
Javascript :: Hide elements until Alpine Js loads 
Javascript :: react native get numeric random string length of 5 characters 
Javascript :: firebase auth sign out javascript 
Javascript :: js conditional object property 
Javascript :: query date range in mongodb 
Javascript :: document ready javacsript 
Javascript :: jquery redirect to url 
Javascript :: word count js 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =