What is state?

State is all of the data contained within an application at any given time. State changes in response to user input and to events that happen within the application, like loading extra data. The state determines what the UI looks like.

State is everything for an application

The application’s state determines how the application looks and behaves in response to user input and to events inside of the application. The user will see different behaviors and outcomes in the application depending on the state of the application.

The state of the application reflects all of the input the user has entered into the application and all of the actions the user has taken. Any data loaded into the application is also part of the state.

State management is a key feature of most JavaScript UI frameworks

State management is not easy. It requires pretty complex logic to keep track of everything and to update the appearance of the application in response to changes in the application’s state. Writing your own code for state management makes bugs or security vulnerabilities more likely.

UI frameworks generally include functionality for easily recording changes to state. These frameworks also usually automatically update the user interface in response to changes in state.

Developers value state management because code is much simpler to write with tools for managing state instead of writing their own code, and managing state is one of the most important parts of developing a web application.