Skip to content

Instantly share code, notes, and snippets.

@mikaelbr
Last active August 29, 2015 14:17
Show Gist options
  • Save mikaelbr/25bc1aba1953c4dc3e84 to your computer and use it in GitHub Desktop.
Save mikaelbr/25bc1aba1953c4dc3e84 to your computer and use it in GitHub Desktop.
var immstruct = require('immstruct');
var component = require('omniscient');
var data = immstruct({ a: {b: { c: { text: 'hello', foo: { bar: 'world' }}}});
var AnotherComp = component((cursor) => /* ... */);
var TextComp = component((cursor) => (
<div>
<p>{cursor.get('text')}</p>
<p>{AnotherComp(data.cursor(['a', 'b', 'c', 'foo', 'bar'])}</p>
</div>
));
var App = component(function (cursor) {
// Use absolute path here
return <div>
<h1>Do something with {cursor.getIn(['a', 'b', 'c'])}</h1>
{TextComp(data.cursor(['a', 'b', 'c']))}
</div>
});
React.render(App(data.cursor()), document.body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment