Created
December 22, 2014 11:47
-
-
Save andrest/ae4a0e69554025bbb4a9 to your computer and use it in GitHub Desktop.
When route '/creator' is selected and the user clicks on the button (see creator_widget.js.jsx below) he's taken back to '/'. Why and how to prevent this?
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 characters
var React = require('react'); | |
var CreatorBox = module.exports = React.createClass({ | |
render: function() { | |
return ( | |
<a href="#" className="btn btn-default" role="button">Button</a> | |
) | |
} | |
}) |
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 characters
var React = require('react'); | |
var Router = require('react-router'); | |
var Route = Router.Route; | |
var RouteHandler = Router.RouteHandler; | |
var Link = Router.Link; | |
var MyApp = React.createClass({ | |
render: function () { | |
return ( | |
<div className="App"> | |
<ul> | |
<li><Link to="/">Index</Link></li> | |
<li><Link to="creator">Faulty Button</Link></li> | |
</ul> | |
<RouteHandler/> | |
</div> | |
); | |
} | |
}); | |
$(document).on("page:change", function() { | |
console.log("hello"); | |
var routes = ( | |
<Route handler={MyApp}> | |
<Route name="creator" path="/creator" handler={require('./creator_widget.js.jsx')}/> | |
</Route> | |
); | |
Router.run(routes, function (Handler) { | |
React.render(<Handler/>, document.getElementById('content')); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
react-router doesn't seem to like href="#" on anchor tags. This seems to be causing the route change.