#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
5 min read
Question 4 of 48easy

useState Hook

Managing state in functional components.

What is useState?

useState is a Hook that lets you add state to functional components. It returns an array with the current state value and a function to update it.

Syntax

code.jsJavaScript
const [state, setState] = useState(initialValue);

Key Points

  • State updates are asynchronous
  • Use functional updates when new state depends on previous state
  • State updates trigger re-renders