Skip to content

realglobe-Inc/sg-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sg-react

Build Status npm Version JS Standard

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.

Links