React useState

The useState hook for managing state.

React useState Hook

The React useState Hook allows us to track state in a function component.

State generally refers to data or properties that need to be tracking in an application.

useState accepts an initial state and returns two values:

  • The current state.
  • A function that updates the state.

Example

const [state, setState] = useState(initialState);