PrivateRouting when Token in Local Storage [TypeScript]

If my login in successful, an authentication token is returned, which is stored in the local storage. Upon successful login, I want to go the a private route. I found this code Javascript snippet but I am unable to make it work for Typescript. I don’t have any isAuthenthicated property yet. How could I modify this accordingly? Here is my login screen: There is a similar question but it doesn’t answer my case since I’m storing the token in local storage. Answer This will go in your index.tsx file: And use this in the browser router/switch: