Я новичок в Redux и следовал учебному пособию по реализации redux в реакции. У меня возникла проблема, которая, кажется, не имеет значения в app.js из функции createStore store.js. Есть идеи?
app.js
import React, { Component } from 'react';
import AppNavbar from './components/AppNavbar';
import ShoppingList from './components/ShoppingList';
import ItemModal from './components/ItemModal';
import { Container } from 'reactstrap';
import { Provider } from 'react-redux';
import store from './store';
import 'bootstrap/dist/css/bootstrap.min.css';
import './App.css';
class App extends Component {
render() {
return (
<Provider store={store}>
<div className="App">
<AppNavbar />
<Container>
<ItemModal />
<ShoppingList />
</Container>
</div>
</Provider>
);
}
}
export default App;
store.js
import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from './reducers';
const initialState = {};
const middleware = [thunk];
const store = createStore(
rootReducer,
initialState,
compose(
applyMiddleware(thunk)
)
);
экспорт магазина по умолчанию;
папка редукторов
itemReducer.js - просто показывается случай GET_ITEMS
import {
GET_ITEMS,
ADD_ITEM,
DELETE_ITEM,
ITEMS_LOADING
} from '../actions/types';
const initialState = {
items: [],
loading: false
};
export default function(state = initialState, action) {
switch (action.type) {
case GET_ITEMS:
return {
...state,
items: action.payload,
loading: false
};
index.js
import { combineReducers } from 'redux';
import itemReducer from './itemReducer';
export default combineReducers({
item: itemReducer
});
Ошибка:
TypeError: Невозможно прочитать свойство 'apply' из неопределенного
(анонимная функция)
C: //client/node_modules/redux/es/redux.js: 523
return funcs.reduce(function (a, b) {
return function () {
return a(b.apply(undefined, arguments));
};
});
}
createStore
C: //client/node_modules/redux/es/redux.js: 87
throw new Error('Expected the enhancer to be a function.');
}
return enhancer(createStore)(reducer, preloadedState);
}
if (typeof reducer !== 'function') {
. / SRC / store.js
C: //client/src/store.js: 9
const middleware = [thunk];
const store = createStore(
rootReducer,
initialState,
compose(