I am stuck with react-router routing. I am getting the error:
Warning: [react-router] Location "/FluxApp/" did not match any routes
This is my app.js:
var React = require('react');
var ReactDOM = require('react-dom');
var Router = require('react-router').Router;
var Route = require('react-router').Route;
var IndexRoute = require('react-router').IndexRoute;
var browserHistory = require('react-router').browserHistory;
var App = require('./views/App');
var Home = require('./views/Home');
var Routes = (<Router history={browserHistory}>
<Route path="/" component={App}>
<IndexRoute component={Home} />
</Route>
</Router>);
ReactDOM.render(Routes, document.getElementById('content'));
My App.js like below:
var React = require('react');
var RouteHandler = require('react-router').RouteHandler;
var App = React.createClass({
render: function() {
return (
<RouteHandler />
);
}
});
module.exports = App;
My Home.js like below:
var React = require('react');
var Home = React.createClass({
render: function() {
return (
<div>
Home
</div>
);
}
});
module.exports = Home;
Here is hieararchy of my project:
/FluxApp
|...
+/js
. |
. +/actions
. +/constants
. +/dispatcher
. +/stores
. +/views
. . |
. . App.js
. . Home.js
. app.js
.
index.html
As you guess, I build app.js with browserify and create bundle.js and I am using that bundle.js in script tag in index.html
Here are versions my everything using in project.
"dependencies": {
"classnames": "^2.2.3",
"flux": "^2.1.1",
"keymirror": "^0.1.1",
"object-assign": "^1.0.0",
"react": "^0.14.6",
"react-dom": "^0.14.6",
"react-router": "^2.0.0-rc5"
},
"devDependencies": {
"browserify": "^6.2.0",
"envify": "^3.0.0",
"jest-cli": "^0.4.3",
"reactify": "^0.15.2",
"uglify-js": "~2.4.15",
"watchify": "^2.1.1"
},
So, when I try to go to "http://localhost:8080/FluxApp/" I get always same error : "Warning: [react-router] Location "/FluxApp/" did not match any routes"
How can i solve this ?
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…