template vs render()
This mental model attempts to reduce the cognitive complexity of authoring components:
- The
templateis a read-only property (initialized with agetkeyword) that represents how the component view is rendered. - There is a
render()method that triggers a view render. - This
render()method is automatically called under the hood every time an attribute value changed. - You can optionally call this
render()method at any point to trigger a render if you need (eg, if you have private unobserved properties that need to manually trigger a render) - Overriding the
render()function for handling a customtemplateis also possible. Here’s an example of usinglit-html: View on CodePen ↗