liveBook · Manning

Rendering

As explained in Web Components in Action

A render method is a component method that returns the markup representing the component's rendered content.

A render method returns the HTML that represents a component’s inner markup. It may run before componentDidMount and again when the component changes, making updates more streamlined without requiring a fixed standard lifecycle hook. section 4.4

Use rendering as an optional design pattern rather than a universal Web Components rule:

  • React permits overriding render to produce the component’s HTML before mounting or after changes. section 4.4
  • Basic Web Components can update innerHTML directly at any time, without being bound to a render lifecycle. section 4.4
  • LitElement and other systems add render methods to streamline HTML updates while adopting rules about when rendering occurs. section 4.4

How Web Components in Action covers it

How deep it goes
Defines returned inner markup and timing, but stops short of implementation details or a complete rendering algorithm.
Examples
Uses returned HTML for component inner markup and contrasts it with direct innerHTML updates.
What it assumes
Assumes familiarity with components, HTML, the DOM, and lifecycle timing.
What you can do after
Evaluate whether a render method or direct innerHTML updates better fit a component’s update design.
How it connects
Connects rendering with React lifecycle methods, Web Components, LitElement, innerHTML, and component updates.

Also explained in

Compare how 4 books explain rendering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Components in Action. The section links point to the parts of the book it draws on.