Nobody's Perfect, Man

    nornj-react

    5.3.4 • Public • Published

    NornJ-React

    React bindings for NornJ template engine.

    NPM Version NPM Downloads

    Install

    npm install nornj-react

    bindTemplate

    You can use bindTemplate to register React components to NornJ template engine.

    • Class components
    import React, { Component } from 'react';
    import ReactDOM from 'react-dom';
    import nj from 'nornj';
    import { bindTemplate } from 'nornj-react';
    
    @bindTemplate
    class TestComponent extends Component {
      render() {
        return <i>{this.props.children}</i>;
      }
    }
    
    ReactDOM.render(nj`<TestComponent>test</TestComponent>`(), document.body);

    In addition, bindTemplate also support a name parameter:

    ...
    import { bindTemplate } from 'nornj-react';
    
    @bindTemplate('test-Component')
    class TestComponent extends Component {
      render() {
        return <i>{this.props.children}</i>;
      }
    }
    
    ReactDOM.render(nj`<test-Component>test</test-Component>`(), document.body);
    • Function components
    import React, { Component } from 'react';
    import ReactDOM from 'react-dom';
    import nj from 'nornj';
    import { bindTemplate } from 'nornj-react';
    
    const TestComponent = bindTemplate('test-Component')(props => (
      <i>{props.children}</i>
    ));
    
    ReactDOM.render(nj`<test-Component>test</test-Component>`(), document.body);

    License

    MIT

    Install

    npm i nornj-react

    DownloadsWeekly Downloads

    277

    Version

    5.3.4

    License

    MIT

    Unpacked Size

    393 kB

    Total Files

    1417

    Last publish

    Collaborators

    • joe_sky