ReactJS Tutorial

Understanding ReactJs useState Hook

What is useState Hook in ReactJS?

We know that there are two types of components in React: class and function.

In class, we initialize the count state to 0 by setting this.state to 0 in the constructor. 


class Example extends React.Component {

  constructor(props) {


    this.state = {

      count: 0



What does useState return?

As discussed earlier, useState returns a pair of values: the current state and a function that updates it.

Did you find this article helpful?