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
From the course: Web Components and Modularization: Practical Approaches
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Plan before you code1m 25s
-
(Locked)
Raw output2m 32s
-
(Locked)
Properties1m 49s
-
(Locked)
Input and output3m 27s
-
(Locked)
State2m 7s
-
(Locked)
Who owns state?2m 11s
-
(Locked)
Life cycle1m 18s
-
(Locked)
Challenge: Scope a complex component1m 20s
-
(Locked)
Solution: Scope a complex component5m 5s
-
(Locked)
-
-