Skip to content

Warning: [react-router] Location did not match any routes #3541

@iiison

Description

@iiison

I know this issue has been raised before, but I couldn't find a proper solution. Here are few details before the issue. I'm using:
React: 15.1.0
React-Dom: 15.1.0
React-Router: 2.4.1

Here is my code:

routes.js

var React = require('react'),
    Router = require('react-router').Router,
    Route = require('react-router').Route,
    IndexRoute = require('react-router').IndexRoute;

var Main = require('../components/Main');
var Home = require('../components/Home');
var Profile = require('../components/Profile');

module.exports = (
    <Route path="/" component={Main}>
        <Route path="profile/:username" component={Profile} />
        <IndexRoute component={Home} />
    </Route>
)

App.js

var React = require('react'),
    ReactDom = require('react-dom'),
    Router = require('react-router').Router;

var routes = require('./config/routes');

ReactDom.render(
    <Router>{routes}</Router>,
    document.getElementById('app')
);

Index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Final React Test</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
</head>
<body>
    <div id="app"></div>
    <script type="text/javascript" src="bundle.js"></script>
</body>
</html>

When I'm am opening the index.html in browser, it works fine, but when I add /profile/test, it doesn't work and console shows the warning by saying:

Warning: [react-router] Location "//profile/test" did not match any routes

I'm not sure why there is an extra / before profile, I'm not sure what am I missing here. Let me know if you need template files too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions