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

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 :: placeholder value javascript 
Javascript :: print placeholder value js 
Javascript :: js querySelectorAll map sample 
Javascript :: convert string in ethers.js 
Javascript :: javascript function argument type 
Javascript :: expressjs path optional parameters 
Javascript :: crop image canvas 
Javascript :: Checking Empty JS Object 
Javascript :: get index of selected option javascript 
Javascript :: js get json keys 
Javascript :: btoa javascript 
Javascript :: how to check if a json object is empty 
Javascript :: how to specify max number of character angular mat input 
Javascript :: send url by whatsapp in javascript 
Javascript :: how to change the color of error message in jquery validation 
Javascript :: how to split string into array javascript 
Javascript :: remove from object javascript 
Javascript :: javascript math.pow 
Javascript :: cancel button in react js 
Javascript :: on function change body background image 
Javascript :: moment js - to find if dates are same by day 
Javascript :: get combinations of two js 
Javascript :: js check if array 
Javascript :: javascript remove item onclick 
Javascript :: How to write inside a div using javascript 
Javascript :: how to add css in js 
Javascript :: “javascript sleep 1 second” 
Javascript :: keyboard event js 
Javascript :: jquery growl cdn 
Javascript :: js camalcase 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =