How to use the useState React hook

Prafful Indirala
1 min readMar 5, 2021

One React hook I most often use is useState.

import React, { useState } from 'react'

Using the useState() API, you can create a new state variable, and have a way to alter it. useState() accepts the initial value of the state item and returns an array containing the state variable, and the function you call to alter the state. Since it returns an array we use array destructuring…

--

--

Prafful Indirala

I create easy to digest Front-end related articles here.Yo'll find me writing about everything from JavaScript basics,to larger framework and library tutorials.