And we're almost done with the nap, the last piece of functionality that is missing is the fact that
our want to save.
Well, what is the preference of the user?
For example, if we select the darkman, I would want to keep it when I refresh them at the moment,
you'll notice that yes user comes here, he or she switches to that.
More than once we reload the app, of course, we go back to the lighting and we're going to say that
value is simply we'll use the local storage and remember that we start asking our repairs and of course,
we'll just save ah the value.
So I'm going to navigate back to our project and I'm going to set up the function, I'll call it get
storage themes of const and then we're going to get storage and then team.
Now I'm not going to pass in any kind of arguments in the function and I'll right away set up my variable.
So my theme variable and by default it is going to be exactly the same light theme.
So we cut it out and copy and paste and then of course I would want to check in my local storage.
Do I have the key by the name of the room?
So I go with if they can get item and the name of the key is going to be theme.
Now, at the moment, of course, there's no value there, but eventually that's how I'm going to set
up my local storage.
And if that is the case, if the key exists that set my variable equal to the value that I'm getting
back now in this case, we don't need to use JSON parts more string for essentially we're just storing
it as string anyway.
So we go get item and then I'll say theme.
And at the end of this function, we're just want to return the theme, whatever it is, if there's
some value in a key, therefore it's going to come back as a value for my variable.
If not, then by default it's going to be like them.
Now, of course I would want to invoke it.
So get storage theme and vacate by default once the applause and that every time I change the theme
value, I also would want to change the key, the key value pair in my local storage.
So we go with local storage that item and find the key that I want to change his name, of course,
and then the value is coming from my state variable.
So now of course I can navigate here now by default theme is lightning.
Of course, once I refresh, it's always going to be light.
But then the moment I change the value in local storage also changes to the Zakim.
So now of course, when my app loads a check and of course in this case I can see that the user preference
is the.
That's why right away the low darkling, hopefully everyone enjoyed the project and I hope the next
one.