An open API service indexing awesome lists of open source software.

https://github.com/uppercod/preact-tag

This small library(<520 bytes umd/gzip) allows to encapsulate the use of components based on Preact and CustomElements.
https://github.com/uppercod/preact-tag

Last synced: about 1 year ago
JSON representation

This small library(<520 bytes umd/gzip) allows to encapsulate the use of components based on Preact and CustomElements.

Awesome Lists containing this project

README

          

# preact-tag

This small library(<520 bytes umd/gzip) allows to encapsulate the use of components based on **Preact** and **CustomElements**.

### JS
```js
import {h,Component} from "preact";
import register from "preact-tag";

register(
"preact-tag",
class extends Component{
static get props(){
return ["title"];
}
render(props){


hello {props.title}



}
}
);
```

### HTML

```html

```

By adding the static method `props` to the component created on the basis of `preact.Component`, you can recover and know the mutations of the properties associated with **CustomElement**.

## prefijo json-{prop}

Any property within the **CustomElement** can be parsed by `JSON.parse`, simply by prefixing the property with the prefix **json-**, then you can use it with `this.props.json`, by default preact-tag, applies camelCase format, to normalize the name of the property.

```js
import {h,Component} from "preact";
import register from "preact-tag";

register(
"preact-tag",
class extends Component{
static get props(){
return ["json-list-users", "json-checked"];
}
render(props){


{props.jsonListUsers.map(({name})=>

{name}


)}


}
}
);
```