What is State in React.JS?

  1. React Components (Functional or Class) are updated at in real time when the state is changed.
  2. Like React Functional Components are not like your normal javascript functions, which needs to be called in order for them to execute. They are executed after every “State Change” in the webapp.
  3. In other words state change define when the functional components are executed.
  4. We can define “State Object” or “State Variables”. There will be inside either React Functional Component (React.FC) or React Class Component.

Reset State

State will be reset when you refresh your browser URL.

Sample Codes

  • State in React Functional Component (useState)
  • State in React Class Component (this.state)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Takshil Patil

Takshil Patil

Learner. Curious about Blockchain Security