关于历史和React路由器之间的不同版本的问题

时间:2018-04-04 04:35:03

标签: reactjs react-router history react-router-dom

我不知道发生了什么事。当我想运行我的反应应用程序并且我收到一条错误消息时,它就开始了:

  

您提供了使用history v4.x或v2.x及更早版本创建的历史记录对象。此版本的React Router仅与v3历史对象兼容。请更改为历史v3.x。

由于我的反应应用程序工作正常,我没有做任何更改。

这是我的App.js代码,其中我使用react-router-dom

import React from 'react';
import {HashRouter as Router, Route} from 'react-router-dom';
import asyncComponent from './AsyncComponent';
import AppShell from './AppShell';
// import authClient from './authClient';
// import Login from './Login';

const Dashboard = asyncComponent(() => {
  return import(/* webpackChunkName: "dashboard" */ './dashboard/Dashboard')
    .then(module => module.default);
});

const Asesmen = asyncComponent(() => {
  return import(/* webpackChunkName: "asesmen" */ './asesmen/Asesmen')
    .then(module => module.default);
});

const AsesmenDetail = asyncComponent(() => {
  return import(/* webpackChunkName: "asesmendetail" */ './asesmen/AsesmenDetail')
    .then(module => module.default);
});

const CreateAsesmen = asyncComponent(() => {
  return import(/* webpackChunkName: "createasesmen" */ './asesmen/CreateAsesmen')
    .then(module => module.default);
});

class App extends React.Component {
  render() {
    return (
      <Router>
        <AppShell>
          <div>
            <Route exact path="/" component={Dashboard} />
            <Route path="/asesmen/" component={Asesmen} />
            <Route path="/asesmendetail/" component={AsesmenDetail} />
            <Route path="/createasesmen/" component={CreateAsesmen} />
          </div>
        </AppShell>
      </Router>
    );
  }
}

export default App;

我真的很期待这个问题的解决方案。

谢谢

0 个答案:

没有答案