Skip to content

Commit

Permalink
Add custom component example
Browse files Browse the repository at this point in the history
goto-bus-stop committed Dec 6, 2018
1 parent 6b1edf9 commit b5ef35c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion example/react.js
Original file line number Diff line number Diff line change
@@ -16,6 +16,15 @@ var hx = hyperx(createElement, {
createFragment: createFragment
})

// use custom components by doing `<${Component}>`
function FancyTable (props) {
return hx`
<table class=fancy>
${props.children}
</table>
`
}

var title = 'world'
var wow = [1,2,3]
var frag = hx`
@@ -30,6 +39,8 @@ var tree = hx`<div>
return hx`<b key="${i}">${w}</b>\n`
})}
<table>${frag}</table>
<${FancyTable}>
${frag}
</${FancyTable}>
</div>`
console.log(toString(tree))

0 comments on commit b5ef35c

Please sign in to comment.