Reputation: 117
React router seems to be appending a query to the end of my routes. The app is being served by a node server running express. I'm using the latest version of react-router "1.0.0-rc1"
Example:
http://localhost:8080/#/users?_k=8wsy62
Two questions
1) Why is this happening?
2) How can I stop it from appending the query to the url?
Here is the code I have so far:
var React = require('react');
var ReactRouter = require('react-router');
var Router = ReactRouter.Router;
var Route = ReactRouter.Route;
var Link = ReactRouter.Link;
var IndexRoute = ReactRouter.IndexRoute;
var App = React.createClass({
render: function() {
return (
<div className="app">
<h1>App</h1>
<Link to="/users">Users</Link>
{this.props.children}
</div>
);
}
});
var Home = React.createClass({
render: function() {
return (
<div className="home">
<h2>Home</h2>
</div>
);
}
});
var Users = React.createClass({
render: function() {
return (
<div className="users">
<h2>Users</h2>
</div>
);
}
});
React.render((
<Router>
<Route path="/" component={App}>
<IndexRoute component={Home} />
<Route path="users" component={Users} />
</Route>
</Router>
), document.body);
Upvotes: 4
Views: 5916
Reputation: 1153
Taken from this link: http://rackt.github.io/history/stable/HashHistoryCaveats.html
HTML5 gives us the pushState method and the popstate event, but in older browsers the only thing we have is the URL. So, when using hash history, you'll see an extra item in your query string that looks something like _k=123abc. This is a key that history uses to look up persistent state data in window.sessionStorage between page loads.
You can check both the link above and this one for ideas on how to stop this if you don't like it: https://github.com/rackt/react-router/issues/1952#issuecomment-140401701
Upvotes: 4