title: React+Redux - Uncaught Error: Expected the reducer to be a function
body: <p>I tried simple react,redux,ajax working example and followed <a href="http://redux.js.org/docs/advanced/ExampleRedditAPI.html" rel="noreferrer">Reddit API tutorial</a>, but I cannot create store and get error:</p>
  
  <pre><code>Uncaught Error: Expected the reducer to be a function.
  </code></pre>
  
  <p><strong>index.jsx</strong></p>
  
  <p>...</p>
  
  <pre><code>import { createStore, applyMiddleware } from 'redux'
  var thunkMiddleware = require('redux-thunk');
  var createLogger = require('redux-logger');
  var rootReducer = require('./reducers.js');
  
          const loggerMiddleware = createLogger();
  
          function configureStore(initialState) {
              return createStore(
                  rootReducer,
                  initialState,
                  applyMiddleware(
                      thunkMiddleware,
                      loggerMiddleware
                  )
              )
          }
  
          const store = configureStore();
  </code></pre>
  
  <p>...</p>
  
  <p><strong>rootReducer.js</strong></p>
  
  <pre><code>import { combineReducers } from 'redux';
  
  function products(state = {
      isFetching: false,
      didInvalidate: false,
      items: []
  }, action) {
      switch (action.type) {
          case 'REQUEST_PRODUCTS':
              return Object.assign({}, state, {
                  isFetching: true,
                  didInvalidate: false
              })
          case 'RECEIVE_PRODUCTS':
              return Object.assign({}, state, {
                  isFetching: false,
                  didInvalidate: false,
                  items: action.posts,
                  lastUpdated: action.receivedAt
              })
          default:
              return state
      }
  }
  
  function specialPosts(state = { }, action) {
      switch (action.type) {
          case RECEIVE_SPECPOSTS:
          case REQUEST_SPECPOSTS:
              return Object.assign({}, state, {
                  req: true
              })
          default:
              return state
      }
  }
  
  const rootReducer = combineReducers({
      products,
      specialPosts
  });
  
  export default rootReducer;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/PNJqK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PNJqK.png" alt="enter image description here"></a></p>
  
  <p>Type of rootReducer is object, but why? Should I change <code>createStore</code> function to <code>rootReducer.default</code>?</p>
  
  <pre><code>return createStore(
      rootReducer.default,
      initialState,
      applyMiddleware(
          thunkMiddleware,
          loggerMiddleware
       )
  )
  </code></pre>
  
  <p><strong>package.json</strong></p>
  
  <pre><code>"redux-logger": "^2.6.1",
  "react-redux": "^4.4.1",
  "react-redux-provide": "^5.2.3",
  "redux": "^3.3.1",
  "redux-thunk": "^2.0.1",
  </code></pre>