All language subtitles for 042 useState - Object Example.en_US

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

Not bad, not bad ones, we have covered how we can use you state whether I think it also makes sense

if we would take a look at how we can use with an object because there is a gotcha.

So, again, we're looking for the set of Holder, then we're looking for use state object.

And once we say we should see the use state object example, and of course, we just need to navigate

to that particular file, which is in the set up again, and then use state object ajaz.

And of course I would want to use my hook.

So let's go with the values.

I'm going to go with person and then that person and that is going to be equal to my use state and then

I'll pass in that object directly.

Again, that is something that I would want you to keep in mind where you can passing the variable like

what you just did with an array, or we can pass in directly.

So in this case, I'll pass in the object what it's going to be name.

Now, that name will be Peter than age will be twenty four.

So let's do that.

And then lastly, we'll have some kind of message message and I'll set this up as a string so beautifully.

I have my object.

So let's call this a random online message so I want to receive.

Of course, we are in good shape, and if we want to consult the person, of course, will be able to

see our object.

Not bad at all.

Now, the thing is, what happens if we change this value and what God you should be looking for?

Because with Aura, it was somewhat straightforward, where in one case we just wiped out all the data

when we set it back to an empty right.

And then the second thing we had the function that was just returning a new era.

Now, this is going to be a little bit different because we'll have some values that we would want to

preserve.

Now, let me showcase what I'm talking about.

I'll start with my return, where I'll set it back to a fragment.

And then in here, let's try a few adding 3s.

So first we'll look for person, name, person and notice, since it is an object, of course I have

my value.

I'm accessing my state value and then I'm just looking for a property.

Now I will copy and paste and I'll just change these ones around where of course we'll have age here.

We'll have also a message and let's say and there it is, Peter.

Twenty four and a random message.

And eventually I would want to have a button that changes the message again, button class nine for

the stylings of Bethanne and then on Click.

And in here, let's call the change message, change message a function that we haven't created yet.

So in button, let's write change message and let's come up with that function.

So in here, consed change message, that is my function.

I'm not looking for any arguments in this case, but I would want to invoke my set person.

Now what you'll notice though, that for example, if I want to change the message to a whole world,

the problem is going to be that when we invoke this function, essentially we wipe out all the values.

Remember I told you when we set up these values, the state where it can be anything that you don't

want.

So even though in the beginning we went with an object, if we invoke the function that changes the

state value and we pass in a string, this will be a string.

So originally we had an object and we're treating like an object or a person named person.

And then the message are here.

I just wipe out the data and then I say, you know what, it is going to be a hellhole.

Now, you could make an argument.

All right, but what if we would set this up as an object and I'll pass in the proper of message.

So in this case, our same message is equal to the world.

And technically, you are correct where now we will change only the message, but again, the rest of

the data gets wiped out.

So what is the solution?

Well, the solution is using a separate operator where if you remember which operator, we first copy

the values and then we come up with whichever value we would want to override.

So how we would fix this in this scenario?

I would go with that and that person and then comma.

And then I'm just going to say, you know what?

Leave these two values, the name and age as they are and overwrite only the message.

So this is the gotcha.

For example, if you're using the object, then you need to make sure that you always, always use the

separate operator.

Or there's also some other older setup where essentially you copy the old values from the state value

and then you just decide which one you would want to choose.

In this case, we want to change the whole world.

So, of course, once we click, notice how we also change only the message.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.