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 react link

<Link to={document.URL.indexOf("http://localhost:3000/contact") - 1 } className='text-black mx-6 flex justify-self-center my-1 font-lato relative'>Go back</Link>
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 :: get the placeholder value jquery 
Javascript :: how to find parent table of tr in jquery 
Javascript :: set default version of node nvm 
Javascript :: javascript fetch api post 
Javascript :: create a new input with type checkbox javascript 
Javascript :: vibrate javascript 
Javascript :: javascript array of cumulative sum 
Javascript :: react style justify content space between 
Javascript :: convert 2 dimensional array to js object 
Javascript :: javascript dom id selector 
Javascript :: bubble sort javascript 
Javascript :: get selected text of html dropdown in javascript 
Javascript :: react dom 
Javascript :: react eslint error missing in props validation 
Javascript :: getting the current url in node js 
Javascript :: javascript Validating the Phone Number 
Javascript :: javascript scroll to bottom 
Javascript :: js array enclose all items with ' 
Javascript :: auto reload page javascript 
Javascript :: get button text javascript 
Javascript :: square all numbers in array javascript 
Javascript :: random code js 
Javascript :: jquery grid get all selected row 
Javascript :: read only javascript 
Javascript :: get buffer from jimp js 
Javascript :: nodejs delete folder recursively 
Javascript :: nodejs put array in file 
Javascript :: pdf.js cdn 
Javascript :: How to get convert number to decimal - jquery 
Javascript :: componentdidmount hooks 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =