react-render-wrapper

    1.0.2 • Public • Published

    react-render-wrapper

    A easy to use factory wrapper for react components. If you don't use jsx then

    //instead of having something like below
    var pager2 = React.render(
           React.createElement(ViewPager.cls,{ 
               views : ["page11","page22","page33"], visible:"page11"}),
       document.getElementById("viewpager-container2"));
     
    //you can expose your component to something liek below instead
    var MyReactClss = require("./myreact-cls"); //React.createClass({});
     
    MyReactClss.render({ options },"documentId" || htmlElementInstance);
    MyReactClss.cls; //the actual class
    MyReactClss.el({options}); //React.createElement(options) wrapper
     

    Usage

    $ npm install react-render-wrapper

    var renderWrapper= require('react-render-wrapper');
    module.exports = renderWrapper(React,MyReactClass);
     
    //and clients can do
    MyReactClass = require('react-myclass');
     
    MyReactClass.render({option:'myoption'},'elementid'); //option and element id
    MyReactClass.render('elementid'); //render directly with default options
    MyReactClass.render($container.find('.cls-cont').get(0)); //render directly with default options
    MyReactClass.el({}); //pass options for React.createElement short cut
     
    //if you use jsx
    React.render(<MyReactClass.cls/>,el);

    Keywords

    none

    Install

    npm i react-render-wrapper

    DownloadsWeekly Downloads

    9

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • wmira