react-redux <Provider> - 空白页

react-redux <Provider> - Blank page

在我开始使用 'react-redux' 之前,我的程序运行得很好。现在我在本地主机上得到一个空白页面,控制台显示错误:

Uncaught TypeError: Found non-callable @@iterator

这是我的代码:

店铺

    import {createStore, applyMiddleware, compose} from 'redux'
    import thunk from 'redux-thunk';
    import rootReducer from './reducers/rootReducer';
    
    import {sessionService} from 'redux-react-session';
    
    const initialState = {};
    const middlewares = {thunk};
    
    const store = createStore(rootReducer, initialState, compose (applyMiddleware(...middlewares)));
    
    sessionService.initSessionService(store);
    
    export default store

rootReducer

    import {combineReducers} from 'redux';
    
    //session
    import {sessionReducer } from "redux-react-session";
    
    const rootReducer = combineReducers ({
        session: sessionReducer
    });
    
    export default rootReducer;

应用程序

    import React from 'react';
    
    // Pages
    import Home from './pages/Home';
    import Login from './pages/Login';
    import Signup from './pages/Signup';
    import Dashboard from './pages/Dashboard';
    
    
    //Styled Components
    import {StyledContainer} from './components/Styles';
    
    import { HashRouter as Router, Route, Routes } from "react-router-dom";
    
    function App() {
      return (
        <Router>
          <StyledContainer>
            <Routes>
              <Route path='/signup' element={<Signup/>} />
    
              <Route path='/login' element={<Login/>} />
    
              <Route path='/dashboard' element={<Dashboard/>} />
    
              <Route path='/' element={<Home/>} />
    
            </Routes>
          </StyledContainer>
        </Router>
      );
    }
    
    export default App;

指数

    import React from 'react';
    import ReactDOM from 'react-dom';
    import './index.css';
    import App from './App';
    
    
    // auth
    import {Provider } from 'react-redux';
    import store from "./auth/store";
    
    ReactDOM.render(
      <React.StrictMode>
        <Provider store={store}>
          <App />
        </Provider>            
      </React.StrictMode>,
      document.getElementById('root')
    );

不知道哪里不对,也没有经验。我正在尝试学习教程:https://www.youtube.com/watch?v=HCnHYz6TXA4
提前致谢!

看起来像 Found non-callable @@iterator in reactjs store

的副本

您正在尝试将展开运算符应用于商店设置中的对象。普通 javascript 对象不可迭代,这就是为什么您收到有关 non-callable @@iterator.

的错误的原因

const middlewares = {thunk};
    
const store = createStore(rootReducer, initialState, compose (applyMiddleware(...middlewares)));

middlewares 应该是一个数组:


const middlewares = [thunk];
    
const store = createStore(rootReducer, initialState, compose (applyMiddleware(...middlewares)));