sg-react

1.1.4 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i sg-react

Weekly Downloads

2

Version

1.1.4

License

Apache-2.0

Last publish

Collaborators

  • realglobe