-
-
Save chrisbuttery/9b009dc3074f74e76421 to your computer and use it in GitHub Desktop.
This file contains 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
import {Button} from './button' | |
import {scene,render,renderString} from 'deku' | |
// returns a scene | |
var app = scene(Button) | |
// Set initial properties | |
app.setProps({ text: 'Submit' }) | |
// Use plugins on the entire scene. Components can | |
// access the scene through context.scene. | |
app.use(channels()) | |
// Set development mode. This will output the rendering | |
// and hook times for each component. | |
app.debug(true) | |
// Render the scene to the body using the DOMRenderer | |
// Returns the renderer object. | |
var mount = render(app, document.body) | |
// The renderer emits events whenever it updates. This is | |
// really only useful for updating | |
mount.on('update', function(){ | |
// updated | |
}) | |
// Update the props. The renderer will re-render | |
// the app on the next frame. | |
app.setProps({ text: 'foo' }) | |
// Remove the scene and it's element from the DOM | |
mount.remove() | |
// Or render the scene to a string | |
renderString(app) | |
// Or render to canvas | |
renderCanvas(app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment