WEBVTT

1
00:00:00.640 --> 00:00:02.100
Hi and welcome back.

2
00:00:02.130 --> 00:00:04.420
Today what I want to explain to you is how

3
00:00:04.450 --> 00:00:08.330
to use the reducer actions
that we have defined here.

4
00:00:08.360 --> 00:00:12.900
For example, update first name in order
to update the first name given here.

5
00:00:12.930 --> 00:00:16.180
So we're going to be updating
Nata to something else.

6
00:00:16.200 --> 00:00:18.180
So for that we're going to need some kind

7
00:00:18.210 --> 00:00:23.380
of event happening and because
of that I'm going to import pressable.

8
00:00:23.400 --> 00:00:25.340
And inside this pressable I'm going to put

9
00:00:25.370 --> 00:00:34.380
a text from React Native and it's going
to say press me to change first name.

10
00:00:34.410 --> 00:00:40.700
Great.
So in order to send a request to update

11
00:00:40.730 --> 00:00:44.860
the first name, we're going to have
to use something called dispatch.

12
00:00:44.890 --> 00:00:50.100
So let's create it here so
that we dispatch an action.

13
00:00:50.130 --> 00:00:51.020
Great.

14
00:00:51.050 --> 00:00:56.640
And the way we use this is on press we're
going to say dispatch,

15
00:00:57.000 --> 00:01:02.640
update first name and we're going to give
it an object first name and we're going

16
00:01:02.670 --> 00:01:06.720
to say that we're changing
the first name to N.

17
00:01:07.120 --> 00:01:11.660
Let's import this from our reducers.
Save this.

18
00:01:11.690 --> 00:01:18.100
And now let's press here and we see that
my first name was updated to N.

19
00:01:18.130 --> 00:01:25.490
And it wasn't only updated in response
to the update, my title changed as well.

20
00:01:25.520 --> 00:01:28.620
So we are able to track all of the state

21
00:01:28.650 --> 00:01:32.980
changes and make the updates
to our screens according to that.

22
00:01:33.010 --> 00:01:37.880
So if I console log the user now

23
00:01:38.600 --> 00:01:45.960
you are going to see that my first name
is actually changed from Nata to N.

24
00:01:46.840 --> 00:01:53.060
And if I reload this, my first name
is going to be changed back to Nata.

25
00:01:53.090 --> 00:01:56.420
And for us to avoid something like this

26
00:01:56.450 --> 00:02:00.820
just in case user goes out
of the application and does something else

27
00:02:00.850 --> 00:02:06.980
and comes back or user completely
quits the application and comes back in.

28
00:02:07.010 --> 00:02:11.450
We don't want to reset to initial
state that was defined in the reducers.

29
00:02:11.480 --> 00:02:12.780
We're going to have to use something

30
00:02:12.810 --> 00:02:19.260
called persistor and we're going
to go to that in the next videos.

31
00:02:19.280 --> 00:02:21.640
Thanks so much for watching
and I'll see you in the next video.

