React Router wildcard not being matched

时间:2017-07-17 15:28:38

标签: javascript reactjs react-router

I'm trying to get my app to just direct to a component when a user clicks on a link the app provides (think email verification). So far this is all I'm getting when I click on the link:

Cannot GET /verify/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1Ni[...]

This is my router code:

import React from 'react';
import {Route, IndexRoute, browserHistory} from 'react-router';
import { Provider } from 'react-redux';
import App from './App';
import Log_In from './components/Log_In/Log_In';
import Sign_Up from './components/Sign_Up/Sign_Up';
import SignUp_Redirect from './components/Sign_Up/SignUp_Redirect';
import Verify from './components/Sign_Up/Verify';
import Sign_Out from './components/Sign_Out/Sign_Out';
import Require_Auth from './components/authentication/require_auth';

export default (
 <Route path="/" component={App}>
  <IndexRoute component={Log_In}/>
  <Route path="signin" component={Log_In}/>
  <Route path="signup" component={Sign_Up}/>
  <Route path="signup_redirect" component={Require_Auth(SignUp_Redirect)}/>
  <Route path="verify/:token" component={Verify}/>
  <Route path="signout" component={Require_Auth(Sign_Out)}/>
 </Route>
);

The component Verify just generates some simple HTML, nothing fancy. I tried putting path="verify/*" but that also doesn't work. All the examples and docs I could find shows the above code for a wildcard. Not sure what else I'm supposed to use. React-router on my project is v. 2.0.1 so I don't know if that has any bearing on this. Any help is appreciated, thanks!

EDIT: Problem fixed. Changed browserHistory to hashHistory.

0 个答案:

没有答案