Created
September 19, 2017 17:53
-
-
Save jongacnik/07389d49c40eed45d46b2f7eca1fb508 to your computer and use it in GitHub Desktop.
component box nanocomponent examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Nanocomponent = require('nanocomponent') | |
var html = require('bel') | |
var c = require('component-box') | |
class MyComponent extends Nanocomponent { | |
createElement (text) { | |
return html`<div>${text}</div>` | |
} | |
} | |
function createMyComponent () { | |
var component = new MyComponent() | |
return function () { | |
return component.render(...arguments) | |
} | |
} | |
c.use({ | |
mycomponent: createMyComponent | |
}) | |
// return and render | |
c('mycomponent')('bam') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Nanocomponent = require('nanocomponent') | |
var html = require('bel') | |
var c = require('component-box') | |
class MyComponent extends Nanocomponent { | |
createElement (text) { | |
return html`<div>${text}</div>` | |
} | |
} | |
function createMyComponent () { | |
return new MyComponent() | |
} | |
c.use({ | |
mycomponent: createMyComponent | |
}) | |
// return and render | |
c('mycomponent').render('bam') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment