rnr-constrained-route

rnr-constrained-route JS library on GitHub rnr-constrained-route JS library on npm Download rnr-constrained-route JS library

Constrained route mixin for react-nested-router

Version 0.1.3 License MIT
rnr-constrained-route has no homepage
rnr-constrained-route JS library on GitHub
rnr-constrained-route JS library on npm
Download rnr-constrained-route JS library

RNR Constrained Route

Constrained route mixin for react-nested-router.

Install

npm install --save rnr-constrained-route

Usage

var Constrainable = require('rnr-constrained-route');

var UserEditHandler = React.createClass({
  mixins      : [ Constrainable ],

  statics : {
    redirectTo : '404',
    pathConstraints : /^\/user\/123\/(create|edit)$/
  },

  render : function() { return React.DOM.div(); }
});

var PageEditHandler = React.createClass({
    mixins : [Constrainable],
    statics : {
        redirectTo : '404',
        paramConstraints : {
            pageId : /^[A-Za-z]+$/,
            action : /^\d+$/
        },
    },
    render : function() { return React.DOM.div(); }
});

React.renderComponent(
    <Route handler={SiteWrapper}>
        <Route path='/user/:userId/:action' handler={UserEditHandler} />
        <Route path='/page/:pageId/:action' handler={PageEditHandler} />
    </Route>,
    document.body
);