35 Advanced Blazor features

 

This chapter covers

  • Creating routes that map requests to Blazor components
  • Navigating between components and receiving route data in a component
  • Using a layout with a routed component
  • Implementing the component lifecycle methods
  • Managing interaction between components and with JavaScript code

In this chapter, I explain how Blazor supports URL routing so that multiple components can be displayed through a single request. I show you how to set up the routing system, how to define routes, and how to create common content in a layout.

This chapter also covers the component lifecycle, which allows components to participate actively in the Blazor environment, which is especially important once you start using the URL routing feature. Finally, this chapter explains the different ways that components can interact outside of the parent-child relationships described in earlier chapters. Table 35.1 puts these features in context.

35.1 Preparing for this chapter

35.2 Using component routing

35.2.1 Preparing the Razor Page

35.2.2 Adding routes to components

35.2.3 Navigating between routed components

35.2.4 Receiving routing data

35.2.5 Defining common content using layouts

35.3 Understanding the component lifecycle methods

35.3.1 Using the lifecycle methods for asynchronous tasks

35.4 Managing component interaction

35.4.1 Using references to child components

35.4.2 Interacting with components from other code

35.4.3 Interacting with components using JavaScript

Summary