我在redux商店里使用历史有问题。
,这是我的store.js
import { applyMiddleware, createStore } from 'redux';
// import { createLogger } from 'redux-logger'
import { composeWithDevTools } from 'redux-devtools-extension/developmentOnly';
import reducer from './reducer'; //Import our reducer
import thunk from 'redux-thunk'
import createHistory from 'history/createBrowserHistory';
export const history = createHistory();
// Build the middleware for intercepting and dispatching navigation actions
const myRouterMiddleware = routerMiddleware(history);
//Create our Store using createStore and the reducer as an argument.
export const store = createStore(
reducer, composeWithDevTools(applyMiddleware(thunk)));我所犯的错误是:
编译失败。
./src/redux/store.js模块未找到:无法解析'/home/salathiel/Documents/realcamuniv/src/redux'中的“历史/创建浏览历史”
发布于 2021-02-25 11:57:53
你试图访问历史的方式是不可取的,这是一个警告
Warning: Please use require("history").createBrowserHistory instead of require("history/createBrowserHistory"). Support for the latter will be removed in the next major release
试试这条路
import { createBrowserHistory } from 'history'
export const history = createBrowserHistory(); https://stackoverflow.com/questions/66367844
复制相似问题