仅仅在项目中引入dva就出现,如下警告
Warning: Please use `require("history").createHashHistory` instead of `require("history/createHashHistory")`. Support for the latter will be removed in the next major release.
仓库地址
https://github.com/Tomny2016/react-dva-antd-project/blob/master/src/index.js
项目代码
import React from 'react';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import dva from 'dva';
// 创建应用
const app = dva()
// 注册视图
app.router (() => <App />);
// 启动应用
app.start ('#root');
serviceWorker.unregister ();
Steps to reproduce the behavior:
1.
2.
Expected behavior
1.
2.
比如:
Warning: Please use require("dva").routerinstead ofrequire("dva/router"). Support for the latter will be removed in the next major release.
Warning: Please use `require("history").createHashHistory` instead of `require("history/createHashHistory")`. Support for the latter will be removed in the next major release.
[email protected] beta 全部走 esm,然后项目中开 tree-shaking 把没用到的功能摇掉,推荐用 require('dva'),而不是 require('dva/router'),所以给了警告。
修改代码,比如:
- import { Link, Switch } from 'dva/router';
+ import { router } from 'dva';
+ const { Link, Switch } = router;
- import dynamic from 'dva/dynamic';
+ import { dynamic } from 'dva';
有个特殊的是 routerRedux,直接从 dva 下取就好了,
- import { routerRedux } from 'dva/router';
+ import { routerRedux } from 'dva';
history 的同理,你应该会解决的。
你这修复的是bate的版本,2.4.1不打算修复了吗?
Most helpful comment
你这修复的是bate的版本,2.4.1不打算修复了吗?