“在‘redux’中找不到导出‘createStore’

问题描述 投票:0回答:1
WARNING in ./node_modules/@redux-saga/core/dist/redux-saga-core.esm.js 1343:21-28
"export 'compose' was not found in 'redux'
 @ ./node_modules/redux-saga/dist/redux-saga-core-npm-proxy.esm.js
 @ ./src/store.js
 @ ./src/App.js
 @ ./src/index.js

WARNING in ./src/store.js 6:21-32
"export 'createStore' was not found in 'redux'
 @ ./src/App.js
 @ ./src/index.js

我面临着创建 redux 存储的问题。在这里,我添加了示例代码。如果我从 App.js 中删除提供程序,它就可以正常工作。谁能帮我解决这个问题吗?

应用程序.js

import React from 'react';
import Layout from './components/Layout';
import { BrowserRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import { store } from './store'

const App = () => {
  return (
      <Provider store={store}>
        <BrowserRouter>
          <Layout/>
        </BrowserRouter>
      </Provider>
  );
}

export default App;

store.js

import { createStore, applyMiddleware } from 'redux'
import createSagaMiddleware from 'redux-saga'

import reducers from './redux';
import sagas from './sagas';

const sagaMiddleware = createSagaMiddleware()

export const store = createStore(
  reducers,
  applyMiddleware(sagaMiddleware)
)

sagaMiddleware.run(sagas)

减速机

import { combineReducers } from 'redux';
import { reducer as auth } from './AuthRedux'

const reducers = combineReducers({
    auth
});

export default reducers;

传奇

import { takeLatest, all } from 'redux-saga/effects';

import api from '../middleware/api';
import { AuthTypes } from '../redux/AuthRedux'
import { signupSaga } from './AuthSaga'

export default function * root () {
    const sagaIndex = [
        yield takeLatest(AuthTypes.SIGNUP, signupSaga, api),
    ];
    yield all(sagaIndex)
}

我想这与 redux 以及我如何导入东西有关,但我不确定那里出了什么问题。😩😩

谢谢

reactjs redux react-redux redux-saga
1个回答
0
投票

在store.js中替换

export const store = createStore(
  reducers,
  applyMiddleware(sagaMiddleware)
)

export const store = createStore(
  reducers,
  {},
  applyMiddleware(sagaMiddleware)
)

只是黑暗中的一支箭,因为它对我有用,也许它应该对你有用

© www.soinside.com 2019 - 2024. All rights reserved.