Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to navigate programatically in class component react router v6

<Navigate to="/dashboard" replace={true} /> (Write this in your dom anywhere) example below;

import { Navigate } from "react-router-dom";

<div>
     {isUserLoggedIn ? (
        <Navigate to="/login" replace={true} />
      ) : null}
</div>
Source by reactrouter.com #
 
PREVIOUS NEXT
Tagged: #navigate #programatically #class #component #react #router
ADD COMMENT
Topic
Name
4+9 =