virtual-widget
Create a virtual-dom widget.
Installation
$ npm install virtual-widget
Usage
// map.jsconst virtualWidget = moduleexports =
// view.jsconst map = moduleexports = view { return }
API
render = virtualWidget(hooks)
Create a new virtual-widget
using hooks. The following hooks are available:
- init: run when the element is first created. Define the instantiation logic here.
- update: run on a re-render. Gives a chance to update state.
- destroy: run before the widget is unmounted. It is passed the HTMLElement associated with the widget that will be removed. Generally used to clean up data and remove hooks.
- render: return a string of HTML for server side rendering. It's recommended to use vdom-to-html for server-side rendering.