Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
private route not rendering private page on state change to loggedIn=true

initially, redux state of isloggedin is false,which then rendered login page. then after page load, I have updated the state to loggedIn, but privateRoute is not redirecting

export default function ProtectedRoute({ children }: any) {
  const isLoggedIn = useSelector((state: State) => state.user.isLoggedIn);
  useEffect(()=>{
      console.log("isLoggedIn",isLoggedIn,children)
  },[isLoggedIn])
  return !isLoggedIn ? <Navigate to="/login"/> : children;
}

I also tried putting isloggedin inside of dependency array so as to re render it on state change, I think it registered the new routes but did not update the already updated page of login. i want to write the redirect logic in this component only

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!