React路由器未显示浏览器历史记录 [英] React router not showing browser history
本文介绍了React路由器未显示浏览器历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从中学习教程但我不断收到此错误:
I'm learning from this tutorial but I keep getting this error:
'react-router'不包含名为'的导出browserHistory'。
'react-router' does not contain an export named 'browserHistory'.
具有react-router的文件是:
The file that has react-router is this:
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, browserHistory } from 'react-router';
import routes from './routes';
ReactDOM.render(
<Router history={browserHistory} routes={routes} />,
document.getElementById('root')
);
推荐答案
你需要获得 browserHistory
现在来自历史模块。
You need to get browserHistory
from the history module now.
import createHistory from 'history/createBrowserHistory'
<请注意,他们最近更改了模块API,因此如果您使用的是最新版本,则导入稍有变化:
Note that they changed the module API recently so if you are using the latest version the import slightly changed:
import { createBrowserHistory } from 'history'
这篇关于React路由器未显示浏览器历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文