inferno-hyperx

1.0.0 • Public • Published

inferno-hyperx

Create composable DOM elements by using tagged template strings with inferno

Why

  • Provides an alternative to JSX
  • Easy to render on both client and server (isomorphic)
  • Easy to read and understand

Install

$ npm install inferno-hyperx

Usage

Server:

var T = require('../index')
var toString = require('inferno-server').renderToString
var assert = require('assert')

var message = 'h1 has rendered!'

var onCreated = function (domNode) {
  console.log('hook will only be called when rendered on DOM')
}

var heading = T`<h1 onCreated=${onCreated}>${ message }</h1>`

assert.equal(toString(heading), '<h1>h1 has rendered!</h1>')

Client:

'use strict'

var T = require('../index')
var InfernoDOM = require('inferno-dom')
var document = require('global/document')
var assert = require('assert')

var message = 'h1 has rendered!'

// Example use of hook
var onCreated = function (domNode) {
  assert(domNode, 'domNode is undefined')
  console.log('onCreated triggered')
}

var heading = T`<h1 onCreated=${onCreated}>${ message }</h1>`

InfernoDOM.render(heading, document.body)

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i inferno-hyperx

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • nlocnila