1 00:00:00,370 --> 00:00:07,480 And we're almost done with the nap, the last piece of functionality that is missing is the fact that 2 00:00:07,480 --> 00:00:08,570 our want to save. 3 00:00:08,860 --> 00:00:11,770 Well, what is the preference of the user? 4 00:00:12,370 --> 00:00:20,140 For example, if we select the darkman, I would want to keep it when I refresh them at the moment, 5 00:00:20,150 --> 00:00:24,600 you'll notice that yes user comes here, he or she switches to that. 6 00:00:24,610 --> 00:00:31,270 More than once we reload the app, of course, we go back to the lighting and we're going to say that 7 00:00:31,280 --> 00:00:38,530 value is simply we'll use the local storage and remember that we start asking our repairs and of course, 8 00:00:38,530 --> 00:00:41,170 we'll just save ah the value. 9 00:00:41,440 --> 00:00:47,830 So I'm going to navigate back to our project and I'm going to set up the function, I'll call it get 10 00:00:47,830 --> 00:00:53,920 storage themes of const and then we're going to get storage and then team. 11 00:00:54,130 --> 00:00:59,260 Now I'm not going to pass in any kind of arguments in the function and I'll right away set up my variable. 12 00:00:59,260 --> 00:01:04,180 So my theme variable and by default it is going to be exactly the same light theme. 13 00:01:04,480 --> 00:01:09,420 So we cut it out and copy and paste and then of course I would want to check in my local storage. 14 00:01:09,760 --> 00:01:12,310 Do I have the key by the name of the room? 15 00:01:12,580 --> 00:01:18,000 So I go with if they can get item and the name of the key is going to be theme. 16 00:01:18,370 --> 00:01:22,750 Now, at the moment, of course, there's no value there, but eventually that's how I'm going to set 17 00:01:22,750 --> 00:01:23,620 up my local storage. 18 00:01:23,950 --> 00:01:30,730 And if that is the case, if the key exists that set my variable equal to the value that I'm getting 19 00:01:30,730 --> 00:01:36,490 back now in this case, we don't need to use JSON parts more string for essentially we're just storing 20 00:01:36,490 --> 00:01:37,750 it as string anyway. 21 00:01:38,020 --> 00:01:41,440 So we go get item and then I'll say theme. 22 00:01:41,770 --> 00:01:47,470 And at the end of this function, we're just want to return the theme, whatever it is, if there's 23 00:01:47,470 --> 00:01:52,840 some value in a key, therefore it's going to come back as a value for my variable. 24 00:01:53,080 --> 00:01:55,450 If not, then by default it's going to be like them. 25 00:01:55,690 --> 00:01:57,130 Now, of course I would want to invoke it. 26 00:01:57,130 --> 00:02:04,270 So get storage theme and vacate by default once the applause and that every time I change the theme 27 00:02:04,270 --> 00:02:10,960 value, I also would want to change the key, the key value pair in my local storage. 28 00:02:11,260 --> 00:02:16,690 So we go with local storage that item and find the key that I want to change his name, of course, 29 00:02:16,930 --> 00:02:21,370 and then the value is coming from my state variable. 30 00:02:21,640 --> 00:02:25,780 So now of course I can navigate here now by default theme is lightning. 31 00:02:26,320 --> 00:02:28,600 Of course, once I refresh, it's always going to be light. 32 00:02:28,840 --> 00:02:34,210 But then the moment I change the value in local storage also changes to the Zakim. 33 00:02:34,540 --> 00:02:41,860 So now of course, when my app loads a check and of course in this case I can see that the user preference 34 00:02:41,870 --> 00:02:42,090 is the. 35 00:02:42,820 --> 00:02:48,940 That's why right away the low darkling, hopefully everyone enjoyed the project and I hope the next 36 00:02:48,940 --> 00:02:49,120 one.