Skip to main content

Command Palette

Search for a command to run...

What is useState() in React?

Updated
1 min read
What is useState() in React?

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); }

More from this blog

R

Raja Muhammad Asher - Senior Software Engineer - Full Stack Developer

157 posts

Full Stack Developer with a passion for building web applications. PHP, Node.js, Laravel, ExpressJS, MySQL, MongoDB. Love collaborating & making a difference