Created
August 26, 2015 17:19
-
-
Save saidimu/2758402f7916f4e35dee to your computer and use it in GitHub Desktop.
A ReactJS redirect component for STML/react-router-component
This file contains 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 characters
// jshint unused:true | |
var React = require('react'); | |
var NavigatableMixin = require('react-router-component').NavigatableMixin; | |
var Redirect = React.createClass({ | |
mixins: [NavigatableMixin], | |
_redirect: function(url) { | |
this.navigate(url); | |
}, | |
propTypes: { | |
url: React.PropTypes.string.isRequired, | |
}, | |
componentDidMount: function() { | |
console.log('Redirecting to %s: ', this.props.url); | |
this._redirect(this.props.url); | |
}, | |
render: function() { | |
return null; | |
} | |
});//Redirect | |
module.exports = Redirect; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi I see that you use React, so I am sure that you will find interesting the https://reactjs.co - this is the free online convention and tutorial book for React.JS Developers. React is not only the View (in MVC) anymore. ReactJS For Dummies: Why & How to Learn React Redux, the Right Way.