1.0.3 • Published 6 years ago

preact-append-child v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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);

Edit 3x3m6zo0wp

Install

$ npm install --save preact-append-child
<script src="https://unpkg.com/preact-append-child@1.0.0/dist/preact-append-child.min.js"></script>

Properties

child

Type: Object

afterAppend

Type: Function

beforeAppend

Type: Function

License

MIT © Ahmet Şimşek

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago