Components
Components are modular and reusable chunks of UI that can be composed together to build rich web experiences while keeping complexity under control. We'll explore how components have a well-defined contract with the outside world, how the tracked
decorator can be used to keep your data and DOM in sync, how to handle user interactions like clicks and form submissions, and how to write quick and effective tests to ensure things work as they should.
-
ComponentsHandling User Interaction
To handle user interaction, we'll need to involve a component with a JavaScript module. We'll create one for the Login form, and use the
{{on}}
modifier and@action
decorator to invoke a component method when a DOM event is fired. We'll explore what would happen if we didn't use these tools in an effort to understand what each of them adds to the process. -
ComponentsTracked Properties and Derived State
In order to add some basic validation to our login form so that a user must be selected in order to authenticate, we'll introduce tracked properties, and explore how vanilla JavaScript getters can be used to create derived state.
-
ComponentsComponent Integration Tests
Now that we've enriched our login experience, we'll write some component integration tests to protect our form validation from future regression.