0.1.0 • Published 5 years ago
microh v0.1.0
microh
A small and simple hyperscript wrapper for vdom libraries such as (but not limited to) Preact, React, and Hyperapp.
Features
- optional attrs
h('h1', 'Hello World')
- inline classNames
h('button.button.is-primary')
- no tag name means div
h('.login-area')
- varargs
h('div', 'Hello', 'World', 'the time is', Date.now())
import { h, render } from 'preact'
import microh from 'microh'
// create a wrapped instance of h by passing it to microh
const m = microh(h)
const vnode = m('ul.list-style',
m('li', 'one'),
m('li', 'two'),
m('li', 'three'),
m('li', 'four')
)
render(vnode, document.body)
Installation
esm modules
import microh from 'https://unpkg.com/microh?module'
Browser
<script src="https://unpkg.com/microh"></script>
<script>
window.microh
</script>
NodeJS
// npm install microh
const microh = require('microh')
Usage
import React from 'react'
import microh from 'microh'
const m = microh(React.createElement)
import { h } from 'preact'
import microh from 'microh'
const m = microh(h)
import { h } from 'hyperapp'
import microh from 'microh'
const m = microh(h)