Sunday, September 6, 2026
Latest:
  • Präsentation für b1
  • Verb “werden” Konjugation
  • In German, verb sein (to be) Konjunktion
  • Wichtige wörter für B1 prüfung
  • What are the main differences between ApplicationContext and BeanFactory?
Upokary

Upokary

Quality information

  • Health
  • Life
  • Fashion
  • Food
  • Code
  • English
  • বাংলা
Technology 

Why useState is asynchronous in ReactJS?

Published: January 1, 2021Last updated: July 31, 2021 asynchronous, useState

The main reason for asynchronous useState is the closure scope around an immutable const value.

We can not do await setState() to make it synchronous. On the very first rendering props and state are assumed to be unchanging.

Treat this.state as if it were immutable.

To achieve this we use const keyword with useState hook.

const [state, setState] = useState('initial');

Between the renders, the value might be different. For a particular render, the value remains constant and of course inside the closures.

Reference:
  • https://stackoverflow.com/questions/54069253/usestate-set-method-not-reflecting-change-immediately

You May Also Like

Big O Notation

June 22, 2023 beroza

The module bcrypt_lib was compiled against a different Nodejs version

May 23, 2020 beroza

Write a Program to Find N-ary Tree Preorder Traversal

January 8, 2023 beroza

How to use useMemo hook in React?

August 20, 2022 beroza

Write a Program to Find N-ary Tree Postorder Traversal

January 8, 2023 beroza

String.equals vs == operator in Java

November 13, 2019 beroza

Difference between session.timeout.ms and max.poll.interval.ms for Kafka

June 9, 2020 beroza

rest_cannot_create Sorry, you are not allowed to create posts as this user in WordPress REST API

July 2, 2019 beroza

Redistribute Characters to Make All Strings Equal

December 30, 2022 beroza

Why Upokary?

Upokary.com is a useful application in everyday life. It provides very handy information regarding every aspect of life. Each and every tip of upokary.com is meant to make life better.

Upokary tools

  • Youtube thumbnail
  • Youtube video downloader

Useful Links

  • Handy code
  • Technology
  • People
  • Programming
  • Quote
  • Travel
  • WordPress
  • IELTS
  • Kids

Pages

  • Sitemap
  • Privacy policy
  • About us
  • Contact us

Support

For any kind of query or question please drop a message in the following email: upokary@gmail.com
Copyright © 2026 Upokary. All rights reserved.