How to use the useState React hook
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…