Last active
August 29, 2015 14:23
-
-
Save eplawless/b17ba00bd3e15cc121a5 to your computer and use it in GitHub Desktop.
Revisions
-
eplawless revised this gist
Jun 16, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,6 +46,8 @@ function getNavigation({ React }) { return router[method].apply(router, arguments); }; }); return Navigation; } export default getNavigation; -
eplawless created this gist
Jun 16, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ import getNavigation from './getNavigation'; import React from 'react'; export default getNavigation({ React }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ function getNavigation({ React }) { var { object } = React.PropTypes; /** * A mixin for components that modify the URL. * * Example: * * import { Navigation } from 'react-router'; * * var MyLink = React.createClass({ * mixins: [ Navigation ], * handleClick(event) { * event.preventDefault(); * this.transitionTo('aRoute', { the: 'params' }, { the: 'query' }); * }, * render() { * return ( * <a onClick={this.handleClick}>Click me!</a> * ); * } * }); */ var Navigation = { contextTypes: { router: object.isRequired } }; var RouterNavigationMethods = [ 'makePath', 'makeHref', 'transitionTo', 'replaceWith', 'go', 'goBack', 'goForward' ]; RouterNavigationMethods.forEach(function (method) { Navigation[method] = function () { var router = this.context.router; return router[method].apply(router, arguments); }; }); } export default getNavigation;