1.1.4 • Published 7 years ago

sg-react v1.1.4

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
7 years ago

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

SignatureDescription
.mount(containerId, Component, props) -> PromiseMount 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