Dva: 关于新版本react-router的dva初始化选项history问题

Created on 30 Nov 2017  ·  1Comment  ·  Source: dvajs/dva

import { browserHistory } from 'dva/router';
const app = dva({
  history: browserHistory,
});

上面这种方式是dva-knowledgemap提供的切换 history 为 browserHistory的方法

引入最新的react-router 4.0没有browserHistory 这个模块
实际的router 对象是BrowserRouter...
现在使用

const app = dva({
  history: BrowserRouter,
});

会报错,现在这里的初始化现在有什么解决方案

Most helpful comment

参考dva-example-user-dashboard。需要添加history依赖

yarn add history
import createHistory from 'history/createBrowserHistory';

const app = dva({
  history: createHistory()
});

>All comments

参考dva-example-user-dashboard。需要添加history依赖

yarn add history
import createHistory from 'history/createBrowserHistory';

const app = dva({
  history: createHistory()
});
Was this page helpful?
0 / 5 - 0 ratings