---
title: "Comment by Egai-Osowor on \"How to prevent React ProtectedRoutes from Redirecting to Login on Page Reload\" | Hashnode"
description: "In solution 2, what purpose does the &quot;userUpdated&quot; state serve?"
url: "https://hashnode.com/posts/how-to-prevent-react-protectedroutes-from-redirecting-to-login-on-page-reload/63e3a5d659e3880adcdfba14/comment/64fede97703e32bdbc1cffda"
---

[Discussion](https://hashnode.com/posts/how-to-prevent-react-protectedroutes-from-redirecting-to-login-on-page-reload/63e3a5d659e3880adcdfba14)

Comment [How to prevent React ProtectedRoutes from Redirecting to Login on Page Reload](https://hashnode.com/posts/how-to-prevent-react-protectedroutes-from-redirecting-to-login-on-page-reload/63e3a5d659e3880adcdfba14)

[Egai-Osowor](https://hashnode.com/@egaiosowor)

[Sep 11, 2023](https://hashnode.com/posts/how-to-prevent-react-protectedroutes-from-redirecting-to-login-on-page-reload/63e3a5d659e3880adcdfba14/comment/64fede97703e32bdbc1cffda)

In solution 2, what purpose does the "userUpdated" state serve?

[Chinenye Anikwenze](https://hashnode.com/@kodervine)

[Sep 11, 2023](https://hashnode.com/posts/how-to-prevent-react-protectedroutes-from-redirecting-to-login-on-page-reload/63e3a5d659e3880adcdfba14/comment/64fede97703e32bdbc1cffda#reply-64fee59653e92fc3391129d8)

It is used to store the state of the user and can be reused within the application.

Now, in retrospect, it's over engineering since the developer can access the local storage and store it in state.

Thanks for pointing this out

[Egai-Osowor](https://hashnode.com/@egaiosowor)

[Sep 11, 2023](https://hashnode.com/posts/how-to-prevent-react-protectedroutes-from-redirecting-to-login-on-page-reload/63e3a5d659e3880adcdfba14/comment/64fede97703e32bdbc1cffda#reply-64ff00ebd3da8dcacfaa5d30)

Yeah, that's true. A simpler approach would be to set "isUserSignedIn" to true after successful login and remove it when the user clicks the logout button. The only logic that will be handled on auth change is setting the current user. [Chinenye Anikwenze](https://hashnode.com/@kodervine)
