preact-append-child
v1.0.3
Published
Simple and lightweight append child component for Preact
Downloads
17
Readme
preact-append-child
Simple and lightweight append child component for Preact; for :atom_symbol: Preact
But why?
To use the dom elements simply and quickly.
Usage
for example json-formatter-js
const { h, Component, render } = require("preact");
import JSONFormatter from "json-formatter-js";
import AppendChild from "preact-append-child";
class Demo extends Component {
constructor() {
super()
this.state = {
json: {
count: 0
}
};
}
componentWillMount() {
setInterval(() => {
this.setState({
json: {
count: ++this.state.json.count
}
})
}, 100)
}
render() {
let formatter = new JSONFormatter(this.state.json);
return (
<div>
<AppendChild child={formatter.render()}/>
</div>
);
}
}
render(<Demo />, document.body);
Install
$ npm install --save preact-append-child
<script src="https://unpkg.com/[email protected]/dist/preact-append-child.min.js"></script>
Properties
child
Type: Object
afterAppend
Type: Function
beforeAppend
Type: Function
License
MIT © Ahmet Şimşek