我想使用history
库,但我收到了这条消息:
https://www.npmjs.com/package/history
TypeError: (0 , _history.createBrowserHistory) is not a function
[0] at Object.<anonymous> (/Users/sm_emamian/Desktop/react js/shadyab/app/helpers/history.helper.js:3:30)
我的帮手:
import { createBrowserHistory } from 'history';
export const historyHelper = createBrowserHistory();
package.json
:
"history": "^1.17.0",
答案 0 :(得分:0)
1.17.0版本具有createHistory而不是createBrowserHistory 检查链接-https://www.npmjs.com/package/history/v/1.17.0
// using an ES6 transpiler, like babel
import { createHistory } from 'history'
// not using an ES6 transpiler
var createHistory = require('history').createHistory
答案 1 :(得分:0)
我认为您应该替换createHistory => createBrowserHistory,如下所示
从“历史”导入{createBrowserHistory}; 导出const历史= createBrowserHistory();
答案 2 :(得分:0)
我也有这个问题 此代码修复此错误
import { createBrowserHistory } from "history"
const history = createBrowserHistory ? createBrowserHistory() : []
export default history