sg-react
v1.1.4
Published
React utility for SUGOS
Downloads
4
Readme
sg-react
React utility for SUGOS
Installation
$ npm install sg-react --save
Usage
'use strict'
const { mount, once } = require('sg-react')
const React = require('react')
// Define an component
const RootComponent = React.createClass({
/* ... */
})
const CONTAINER_ID = 'my-mount-root-element'
once('DOMContentLoaded', () => {
// Create an element from the component and mount it to the DOM tree.
mount(CONTAINER_ID, RootComponent, {
// React props
foo: 'bar'
}).then(() => {
// Promise callback when done.
console.log('component mounted!')
})
})
Functions
Available functions
| Signature | Description |
| ---- | ----------- |
| .mount(containerId, Component, props) -> Promise
| Mount a react component into DOM tree. |
| .once(event, handler)
| Bind window event once |
License
This software is released under the Apache-2.0 License.