我使用browserhistory进行路由,但是在重新加载组件时出错了。相反,我使用了hashhistory作为路由,但是url包含不会从url中删除的哈希。但刷新哈希工作。我想在url中使用refresh而不使用hash进行路由?
import React from 'react';
import { createStore, combineReducers, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router, Route, hashHistory } from 'react-router';
import { homeReducer } from 'src/reducers/homeReducer';
// Import the components used as po
import auth from 'src/common/auth.js';
import Login from './login.jsx';
import Homepage from './homepage.jsx';
import Signup from './signup.jsx';
import UserHomepage from 'src/containers/user/homepage.jsx';
// Creates the Redux reducer with the redux-thunk middleware, which allows us
// to do asynchronous things in the actions
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore);
const store = createStoreWithMiddleware(homeReducer);
// check if the path is login that way we can apply specific logic to display/render the path we want to
function checkAuth(nextState, replace) {
}
// Mostly boilerplate, except for the Routes. These are the po you can go to,
// which are all wrapped in the App component, which contains the navigation etc
ReactDOM.render(
<Provider store={store}>
<Router history={hashHistory}>
<Route path="/homepage" component={Homepage} />
<Route path="/login" component={Login} />
<Route path="/signup" component={Signup} />
<Route path="/dashboard" component={UserHomepage} />
<Route path="/" component={Homepage} />
<Route path="*" component={Homepage} />
</Router>
</Provider>,
document.getElementById('app')
);
&#13;