inferno-hyperx
v1.0.0
Published
Create composable DOM elements by using tagged template strings with [inferno](https://www.npmjs.com/package/inferno)
Downloads
1
Readme
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