title: Why is my reducer not triggered using redux?
body: <p>Good morning everyone,</p>
  <p>I just set up redux on my react project. What i am willing to do is to get data when the component Dashboard is rendered. Data are expenses and incomes variables, which are the sum of all the expenses and incomes.</p>
  <p>The problem i get is that my reducer is never triggered. I get no error in my console.
  As you can see in actions/dashboard.js, i consoled log when the call to fetchdata is done, and is working correctly. but the call to setBalance does not.</p>
  <p>In the reducers/dashboard.js, in the switch case, the default case is always triggered, it's like it does not find the action type.</p>
  <p>My Component Dashboard.js</p>
  <pre><code>import React, {useEffect} from 'react'
  
  import classes from './Dashboad.module.css'
  import { Doughnut } from 'react-chartjs-2'
  import {connect} from 'react-redux'
  import * as actions from '../../store/actions/index'
  
  const DashBoard = (props) =&gt; {
  
      useEffect(() =&gt; {
          props.onFetchData()
      }, [])
  // ----------------------------------- Hidden code to not overload the topic -------------------
  const mapStateToProps = state =&gt; {
      return {
          incomes: state.incomes,
          expenses: state.expenses
      }
  }
  
  const mapDispatchToProps = dispatch =&gt; {
      return {
          onFetchData: () =&gt; dispatch(actions.fetchData),
      }
  }
  
  export default connect(mapStateToProps,mapDispatchToProps)(DashBoard);
  </code></pre>
  <p>actions/index.js :</p>
  <pre><code>export {
      fetchData
  } from './dashboard'
  </code></pre>
  <p>actions/actionsTypes.js :</p>
  <pre><code>export const SET_BALANCE = 'SET_BALANCE'
  </code></pre>
  <p>actions/Dashboard.js</p>
  <pre><code>import * as actionsTypes from './actionsTypes'
  import axios from '../../axios'
  
  export const setBalance = (donnees) =&gt; {
      console.log('setbalance')
      return {
          type: actionsTypes.SET_BALANCE, 
          donnees: donnees
      }
  }
  
  export const fetchData = () =&gt; {
      console.log('call fetchdata')
      return dispatch =&gt; {
          axios.get('/movements.json')
          .then(response =&gt; {
              dispatch(setBalance(response.data))
              console.log(response.data)
          })
          .catch(error =&gt; console.log(error))
      }
  }
  </code></pre>
  <p>Reducers/Dashboard.js :</p>
  <pre><code>import * as actionsTypes from '../actions/actionsTypes'
  
  const initialState = { 
      incomes: 0, 
      expenses: 0
  }
  
  const setBalance = (state, action) =&gt; {
      let fetchedMvts = []
      for(let key in action.donnees.data) {
          fetchedMvts.push({...action.donnees.data[key]})
      }
      let sumIncome = 0;
      let sumOutcome = 0;
      fetchedMvts.forEach(element =&gt; {
          let parsed = parseInt(element.amount, 10)
          if(element.type === &quot;income&quot;) {
              sumIncome = sumIncome + parsed;
          } else {
              sumOutcome = sumOutcome + parsed;
          }
      })
      return {...state, incomes: sumIncome, expenses: sumOutcome}
  }
  
  const reducer = (state= initialState, action) =&gt; {
      console.log('TYPE', action.type)
      switch (action.type) {
          case actionsTypes.SET_BALANCE: return setBalance(state, action);
          default: 
          console.log('problem')
          return state;
      }
  }
  
  export default reducer;
  </code></pre>
  <p>And, in case you need it, the index.js file of my app :</p>
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import './index.css';
  import App from './App';
  import { Provider } from 'react-redux'
  import { createStore, applyMiddleware} from 'redux'
  import * as serviceWorker from './serviceWorker';
  import RootReducer from './store/reducers/dashboard'
  import thunk from 'redux-thunk'
  
  const store = createStore(RootReducer, applyMiddleware(thunk))
  
  ReactDOM.render(
    &lt;Provider store={store}&gt;
      &lt;React.StrictMode&gt;
      &lt;App /&gt;
    &lt;/React.StrictMode&gt;
    &lt;/Provider&gt;,
    document.getElementById('root')
  );
  
  serviceWorker.unregister();
  </code></pre>
  <p>Thank you for your help guys</p>
  <p>Have a nice day</p>