Skip to content
This repository has been archived by the owner on Nov 14, 2020. It is now read-only.

Latest commit

 

History

History
41 lines (27 loc) · 933 Bytes

README.md

File metadata and controls

41 lines (27 loc) · 933 Bytes

Hyperscriptor

Super simple hyperscript helper on 21 lines

Usage

Requires peer dependency preact

npm install hyperscriptor
import { render } from 'preact'
import { div, h1, h2 } from 'hyperscriptor'

const CoolHeadings = () => div({}, [
  h1({}, 'HYPERSCRIPTOR!')
  h2({}, 'Here is a subheading')
])

render(CoolHeading(), document.body)

API

element(props, children)

props work as expected, just pass in an object with the corresponding keys. children can be a string, element or array.

Unable to find a proper api documentation for preact's h function, I leave you with react's createElement which is practically indentical.

TBD

  • Add support for using custom hyperscript functions, such as react's createElement.

  • Make it generic, not preact specific