Okay.
And one more thing that I want to add to our application is the check for the user on the landing page.
So that's something that students have been asking.
They're like, look, if the user has currently logged in, why we still display the landing page.
Colin just set up some kind of functionality where if the user exists, then basically we right away
navigate back to the dashboard just to showcase that.
Let me log.
In my application.
Yep.
As you can see, everything.
And I was successful.
And then if let's say I go here to forward slash landing.
I'll be able to navigate there.
And some students say that a better user experience would be if, let's say, right away, we kick back
the user to the dashboard.
And that is something we can do effectively.
Here's the plan.
We want to get the user from user context.
And of course, we need to get the user app context from the app context.
We also want to get the navigate component and we just want to set up the check here on top of the return.
We want to wrap this in a React fragment because those are two adjacent elements over here.
So therefore it will set up the React Fragment and then inside of it we're going to go with user.
And then we'll navigate if the user exists.
If not, then we'll display rest of the code.
And just one last thing that I want to mention.
This is not going to happen in some time.
This will happen immediately, unlike the register page where remember we had that code.
For the use effect, correct?
Where we are checking for the user and then with the set timeout, we essentially navigate it.
This is not the case.
This will happen immediately.
So let's go to the landing.
One, we want to import both of those things.
Like I said, we want to get the navigate from React and we already have the links so we can cheat the
little bit.
We can say navigate.
Navigate.
Hook.
Great.
Good.
And then let's also set up the import for use app context.
So let's go here with import than use context.
Yep, that's the important.
And on top of it, let's get the user from our main context.
So user manual is equal to use context, we want to invoke the hook and then like I said, we are returning
to adjacent elements.
So we want to go with React Fragment, which essentially will allow us to do that.
That is going to be our main return.
So let me put it here.
And then on top of the rapper, simply want to set up the check for the user.
If the user exists, awesome.
Want to navigate to and then this is really up to you.
I'm going to go to the.
Homepage.
Like, so let's say that and then let's try it out.
So if everything is correct, if I have the cookie and all that, by the way, let me check the application.
Notice this is the cookie, if everything is correct.
If let's say I go to the landing and I say, no, I technically don't need the cookie as long as the
user is there, but I'm just showcasing what would happen if I would refresh notice.
So we go technically to the landing, but we right away kick to user back.
That's essentially what's happening.
So the user doesn't stay there long.
And with this in place now, we can worry about the logout feature.