From the course: Web Components and Modularization: Practical Approaches

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

State

State

- [Instructor] In addition to handling dynamic data passed through properties, components can also be set up to have different states. State is an established pattern on the web platform. You see them in things like links, and radio buttons, and form fields, and so on. While properties are used to pass that up to a component, state is used to manage data within that component. State is also private, meaning it's not available outside of the components. You'll remember I said, components should not know about the state of other components. This is what I'm talking about. State allows us to set and change the state of a component or something within the component based on user behavior or other factors. This adds an extra level of dynamic functionality to a component, and enables us to build more advanced components. In our example project, there is an example of a state change. When the user clicks on the Add To Cart…

Contents