Debug School

rakesh kumar
rakesh kumar

Posted on

How to redirect route while click text in react js

step1: add function while button click

Image description

step2: put routing inside function

  const handleRedirect = () => {
    navigate("/review_report")
  };

Enter fullscreen mode Exit fullscreen mode

step3: import class

import { useNavigate } from "react-router-dom"
Enter fullscreen mode Exit fullscreen mode

step4: define navigate

 const navigate = useNavigate()
Enter fullscreen mode Exit fullscreen mode

step5: mention route

  <Route path="review_report" element={<ReviewReport />} />
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

Image description

output

Image description

Image description

Top comments (0)