Fix delayed state update in React. Receiving Previous value of state.

Fix delayed state update in React. Receiving Previous value of state.

Manish Chahar

1 год назад

14,465 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@jahidhassan9329
@jahidhassan9329 - 29.11.2023 02:06

But you are not checking if the state value is changin or not. You are just printing the value of e.target.value on CallAPI method. I tried this my state is not updating immedietly.

Ответить
@yonathanhailemelekot5238
@yonathanhailemelekot5238 - 18.11.2023 23:32

Brilliant

Ответить
@codingisfun-pranayharishch3001
@codingisfun-pranayharishch3001 - 08.09.2023 02:59

thank you so much sir

Ответить
@prajwalpatil8579
@prajwalpatil8579 - 27.08.2023 13:32

if we use setState method with callback will it fix the delay issue?

Ответить
@sr.wyller2022
@sr.wyller2022 - 23.08.2023 22:44

you didn't fixed the state delay, you just used another way to inform de data to your function

Ответить
@basukivenkatpati3052
@basukivenkatpati3052 - 14.08.2023 00:20

then what is the benefit of having state if every time we are hardcoding the values?

Ответить
@krishnenduk893
@krishnenduk893 - 06.08.2023 18:53

Thankyou so much sir

Ответить
@saharil9442
@saharil9442 - 26.06.2023 09:21

Sorry,...
the searchText used is only from the variable from callApi, not from the state's searchText

Ответить
@syedjameelakhter9016
@syedjameelakhter9016 - 13.06.2023 12:44

thanks bro

Ответить
@johanesalberto6136
@johanesalberto6136 - 06.06.2023 09:43

thank you so much brother

Ответить
@munawirulhadi2864
@munawirulhadi2864 - 22.05.2023 12:33

thanks bro, you saved me days of bug fixing ☺️

Ответить
@AkshayKumar-qe2qg
@AkshayKumar-qe2qg - 28.03.2023 09:39

Thanks.helped it

Ответить
@n-az563
@n-az563 - 28.02.2023 10:17

In project it worked for me
Thank you 💓💓💓

Ответить
@sayamgandhak6105
@sayamgandhak6105 - 27.02.2023 09:36

you said 'setState' is async that's actually incorrect . setState is synchronous . React take time to update because of 'batch updating ' . That's means react will update states together to improve the performance by not making component render on every state

Ответить
@sahilbisht3661
@sahilbisht3661 - 03.02.2023 08:21

If it’s not updating instantly then how serchtext value in h1 is getting updated

Ответить
@topote5224
@topote5224 - 03.01.2023 04:55

You got me out of days of bug searching, thank you!

Ответить
@kacperkepinski4990
@kacperkepinski4990 - 04.12.2022 20:47

so how to setValues properly?

Ответить
@jenasusil6
@jenasusil6 - 19.11.2022 15:29

if you are passing one text field value ,thats fine. what if i will pass multilpe input text value to URL? suppose some id, and based on those ID i will fetch API.

Ответить
@balaobireddy
@balaobireddy - 12.10.2022 19:23

Then what is the use of setState

Ответить
@tosinakerele2937
@tosinakerele2937 - 16.08.2022 11:56

nice

Ответить