Skip to content

bjyoungblood/rnr-constrained-route

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
);

About

Constrained route mixin for react-nested-router

Resources

License

Stars

Watchers

Forks

Packages

No packages published