Skip to content

Instantly share code, notes, and snippets.

@rbiggs
Created September 6, 2017 02:19
Show Gist options
  • Save rbiggs/3c95057ae5669e73530b91c049631dda to your computer and use it in GitHub Desktop.
Save rbiggs/3c95057ae5669e73530b91c049631dda to your computer and use it in GitHub Desktop.
Component that consumes an object.
import {h, Component} from 'composi'
const personData = {
name: {
first: 'Joe',
last: 'Bodoni'
},
age: 26,
job: 'mechanic'
}
const person = new Component({
root: '#personDiv',
state: personData,
render: (person) => (
<div>
<h2>Name: {person.name.last}, {person.name.first}</h2>
<h3>Age: {person.age}</h3>
<p>Job: {person.job}</p>
</div>)
})
person.update()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment