microh

0.1.0 • Public • Published

microh npm size

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)

playground

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

React

import React from 'react'
import microh from 'microh'

const m = microh(React.createElement)

Preact

import { h } from 'preact'
import microh from 'microh'

const m = microh(h)

Hyperapp

import { h } from 'hyperapp'
import microh from 'microh'

const m = microh(h)

Package Sidebar

Install

npm i microh

Weekly Downloads

5

Version

0.1.0

License

MIT

Unpacked Size

11.6 kB

Total Files

11

Last publish

Collaborators

  • fuzetsu