title: How to dispatch an action from reducer react-redux
body: <p>I use an event listener in one of my reducers and I need to trigger an action according to the incoming 'type'. I can listen the events i can see the payloads but i cant dispatch another action. The only thing i need to do is dispatch an action. How can I do that ? I cant dispatch from reducer. Im using redux-thunk. I tried to use it with middleware but i cant success. Thank you.</p>
  <pre><code>import { ADD_NOTIF, REMOVE_NOTIF, CLOSE_NOTIFS } from './actions';
  import Notifications from &quot;../util/Notifications&quot;;
  import { addNotif } from &quot;./actions&quot;
  const localStatus = JSON.parse(localStorage.getItem(&quot;notifStatus&quot;));
  const initialState = { notif: [], notifStatus: localStatus !== null ? localStatus : true }
  
  const NotifReducer = (state = initialState, action) =&gt; {
    switch (action.type) {
      case ADD_NOTIF:
        return {
          ...state,
          notif: action.payload,
        };
      case REMOVE_NOTIF:
        return {
          ...state,
          notif: state.notif.filter(i =&gt; i.id !== action.payload.id)
        };
      case CLOSE_NOTIFS:
        localStorage.setItem(&quot;notifStatus&quot;, JSON.stringify(action.payload.status));
        return {
          ...state,
          notifStatus: action.payload.status,
        };
      case 'TWITTER_NET_TWEET':
        return {
          ...state,
          notifStatus: action.payload.tweet
        }
      case 'PHOTO_SAVE_ERROR':
        // Here i have to dispatch addNotif
        return {
          ...state,
        }
      default:
        return state;
    }
  };
  </code></pre>
  <p>The file i combine the reducers;</p>
  <pre><code>import { createStore, combineReducers, applyMiddleware, compose } from &quot;redux&quot;;
  import thunk from &quot;redux-thunk&quot;;
  
  import appReducer from 'containers/Main/reducer';
  import notifReducer from '../src/redux/notifreducer';
  import GalleryReducer from '../src/redux/Gallery/gallery-reducer';
  import PlaneModeReducer from '../src/redux/planeModereducer';
  import ContactsReducer from '../src/redux/Contacts/contactsReducer';
  import CallReducer from '../src/redux/CallModule/callReducer';
  import BackgroundReducer from '../src/redux/Background/background-reducer';
  import SoundsReducer from '../src/redux/Sounds/soundsReducer';
  import TwitterReducer from '../src/redux/Twitter/twitter-reducer';
  import SahibindenReducer from '../src/redux/Sahibinden/sahibinden-reducer';
  import BadgeReducer from '../src/redux/BadgeNotifications/badgeReducer';
  import NewsReducer from &quot;../src/redux/News/newsReducer&quot;;
  import NotesReducer from &quot;../src/redux/Notes/notesReducer&quot;;
  import MessagesReducer from &quot;../src/redux/Messages/messagesReducer&quot;;
  
    const reducers = combineReducers({
      app: appReducer,
      notif: notifReducer,
      gallery: GalleryReducer,
      planeMode: PlaneModeReducer,
      contacts: ContactsReducer,
      inCall: CallReducer,
      background: BackgroundReducer,
      sounds: SoundsReducer,
      twitter: TwitterReducer,
      sahibinden: SahibindenReducer,
      openedApp: BadgeReducer,
      news: NewsReducer,
      messages: MessagesReducer,
      notes: NotesReducer
    });
  
  const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
  
  const store = createStore(
    reducers,
    composeEnhancers(applyMiddleware(thunk))
  );
  
  export default store;
  </code></pre>