Raja Muhammad Asher
Raja Muhammad Asher

Raja Muhammad Asher

What is useState() in React?

Photo by Lautaro Andreani on Unsplash

What is useState() in React?

Raja Muhammad Asher's photo
Raja Muhammad Asher
·Aug 4, 2022·

1 min read

useState is a React Hook that lets you track data or properties in your component.

const [state, setState] = useState(initialState)

You can initialize the state while declaring it and then setState in response to any event like

function handleClick() { setState(newState); }

 
Share this