0

When using functional component, we use useNavigate hook like:

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

function App() {
  const navigate = useNavigate();

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

What is the alternative in Class component using Version 6 of react-router-dom?

Drew Reese
  • 103,803
  • 12
  • 69
  • 96
Medinho
  • 155
  • 1
  • 8
  • There no support for class component in v6 you can refer to this https://github.com/remix-run/react-router/issues/8146#issuecomment-947860640 – hassanqshi Feb 01 '22 at 12:54

0 Answers0