In which React hook do you get the ability to manage state in functional components?

  • useState()
  • componentDidUpdate()
  • setState()
  • this.state = {}
In functional components in React, you can manage state using the useState() hook. It allows functional components to maintain state, similar to how class components handle state using this.setState({}). The other options, componentDidUpdate(), setState(), and this.state = {}, are not used in functional components for state management.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *