Improve code sample for lit integration (#991)

Align the lit component with the astro import and usage of it.
This commit is contained in:
tobi-or-not-tobi 2021-08-03 14:18:11 +02:00 committed by GitHub
parent 27672096f5
commit 418bc1d91c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,13 +36,15 @@ __src/components/my-element.js__
```js
import { LitElement, html } from 'lit';
export const tagName = 'my-counter';
class Counter extends LitElement {
export const tagName = 'my-element';
class MyElement extends LitElement {
render() {
return html` <p>Hello world! From my-element</p> `;
}
}
customElements.define(tagName, Counter);
customElements.define(tagName, MyElement);
```
> Note that exporting the `tagName` is __required__ if you want to use the tag name in your templates. Otherwise you can export and use the constructor, like with non custom element frameworks.