# vdom-component

> Component framework built on `virtual-dom`.

Latest version **0.0.1** (published 2015-09-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install vdom-component
pnpm add vdom-component
yarn add vdom-component
bun add vdom-component
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2015-09-01 |
| First published | 2015-09-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | jameslnewell |

## Links

- npm: https://www.npmjs.com/package/vdom-component
- npm.io page: https://npm.io/package/vdom-component

## Recent versions

- 0.0.1 (latest) — 2015-09-01

## README

# vdom-component

Component framework built on `virtual-dom`.

**STATUS:** *EXPERIMENTAL*

## Installation

    npm i --save vdom-component

## Usage
    
    var h = require('virtual-dom/h');
    var queue = require('vdom-render-queue');
    var component = require('vdom-component');
    
    // --- define the component ---
    
    var App = {
    
      controller: {
    
        onInit: function() {
          this.state.count = 0;
        },
    
        onClick: function() {
          this.state.count++;
          this.props.render();
        }
    
      },
    
      view: function(ctl) {
        return h('div', [
          h('span', ['Clicked ', ctl.state.count, ' times!']),
          h('button', {onclick: ctl.onClick.bind(ctl)}, 'Increment')
        ]);
      }
    
    };
    
    // --- render the component ---
    
    var render = queue(document.getElementById('app'), function() {
      return component(App, {render: render});
    });
    
    render();
  
## API

### controller

#### .onInit()

Called after the component state is initialised.

#### .onAttach(el)

Called after the component has been attached to the DOM.

#### .onDetach(el)

Called before the component has been removed from the DOM.
  
## ToDo

- JSX
- plugin api for stuff like default props and state


## License

The MIT License (MIT)

Copyright (c) 2015 James Newell

---
_Source: https://npm.io/package/vdom-component · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
